I use this with cron to timeshift radio programs from a station's live stream. You will get an error message at the end like "curl: (28) Operation timed out after 10000 milliseconds with 185574 bytes received"; to suppress that but not other error messages, you can append "2>&1 | grep -v "(28)"" to the end of the command.
Once issuing the command, hit "esc" and then "k" (not together) to enter the search mode at the shell prompt (each time), and invoke the search with "/" as if you would in vi. Type a command and see the most recently used instance of that command. Use "n" and "N" to go forward and backwards through other instances of that command.
I have come across multiple situations where I could only get to a server from a very restrictive bounce point which would not allow file transfers. I was able to uuencode a file, copy the output to a text file over putty, and then uudecode the file to transfer it. This works with any kind of file. Show Sample Output
Doesn't display the matching line. If you want that behaviour, you need to add "print && " before the 'exit'.
If BREs can be used, this sed version will also get the job done.
This command line will display the output of , from the first line of output, until the first time it sees a pattern matching . You could specify the regex pattern /^$/ to look for the first blank line, or /^foobar/ to look for the first line that starts with the word foobar.
Exclude 400 client hosts with NFS auto-mounted home directories. Easily modified for inclusion in your scripts. Show Sample Output
print the lines of a file in randomized order Show Sample Output
Once I wrote a command line calculator program in C, then I found this... and added to it a bit.
For ease of use I normally use this in a tiny Perl program (which I call pc for 'Perl Calculator')
#!/usr/bin/perl -w
die "Usage: $0 MATHS\n" unless(@ARGV);for(@ARGV){s/x/*/g;s/v/sqrt /g;s/\^/**/g};
print eval(join('',@ARGV)),$/;
It handles square roots, power, modulus:
pc 1+2 (1 plus 2)
3
pc 3x4 (3 times 4)
12
pc 5^6 (5 to the power of 6)
15625
pc v 49 ( square root of 49 )
7
pc 12/3 (12 divided by 3)
4
pc 19%4 (19 modulus 4)
3
(you can string maths together too)
pc 10 x 10 x 10
1000
pc 10 + 10 + 10 / 2
25
pc 7 x v49
49
Show Sample Output
"Copying" things to the X clipboard doesn't normally create a copy. Rather the data to be 'copied' is referenced. This means that if the application that you 'copied' stuff from is closed, that data is lost. If the application that you 'copied' from is suspended with CTRL-Z, there could be some issues if you try to paste it into something. This command will create a copy of referenced data and have xclip be the provider of it, so you can then go ahead and close the app that contains the original information. Caveat: I'm not sure if this is binary-safe (though i would expect it to be), and don't know what would happen if you used it to clip a 20 meg gimp image. This technique becomes more convenient if you set it up as an action in a clipboard manager (eg klipper, parcellite). Some of these applets can take automatic action based on a variety of parameters, so you could probably just get it to always own the clipped data whenever data is clipped.
The +short option should make dig less chatty.
I'm just a simple programmer. I find dig too verbose. host tells me alias(es) and IP address in a quick to grok format with nothing special to remember for input parameters. With thanks to http://www.cyberciti.biz/faq/how-to-test-or-check-reverse-dns/ Show Sample Output
After ssh into server, run this command to show all the table structure and schema. Show Sample Output
This command will show you amount of memory used by apache Show Sample Output
Avoids creating useless directory entries in archive, and sorts files by (roughly) extension, which is likely to group similar files together for better compression. 1%-5% improvement.
Use `tar xj` for bzip2 archives.
Using awk, find duplicates in a file without sorting, which reorders the contents. awk will not reorder them, and still find and remove duplicates which you can then redirect into another file.
You can return to defaults with "setxkbmap". More here: http://dailycli.blogspot.com/2009/12/xmodmap-replace-caps-lock-with-left.html
Useful with new unknown devices or just monitoring, probably useful for the sysadmin. Updates every 2 seconds. More here: http://linuxclisecurity.blogspot.com/2009/12/monitor-kernel-ring-buffer.html.
commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.
Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.
» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10
Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):
Subscribe to the feed for: