commandlinefu.com is the place to record those command-line gems that you return to again and again.
Delete that bloated snippets file you've been using and share your personal repository with the world. 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.
If you have a new feature suggestion or find a bug, please get in touch via http://commandlinefu.uservoice.com/
You can sign-in using OpenID credentials, or register a traditional username and password.
First-time OpenID users will be automatically assigned a username which can be changed after signing in.
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.
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:
This doesn't work in bash, but in zsh you can typeset -T to bind a scalar variable to an array. $PATH and $path behave this way by default.
You can get others rates changing the "EUR/US" part. look at the url: wap.kitco.com/exrate.wml to get more options.
I like the order of the arguments better this way.
get diskusage of files (in this case logfiles in /var/log) modified during the last n days:
sudo find /var/log/ -mtime -n -type f | xargs du -ch
n -> last modified n*24 hours ago
Numeric arguments can be specified as
+n for greater than n,
-n for less than n,
n for exactly n.
=> so 7*24 hours (about 7 days) is -7
sudo find /var/log/ -mtime -7 -type f | xargs du -ch | tail -n1
The unlock command for KDE 4.3 has changed from krunner_lock, this process doesn't exist anymore. So here's the update :-)
If qdbus complains about not being able to find X, put a "DISPLAY=:0 " (:0 being your X server display) in front of the command.
'jot' does not come with most *nix distros, so we need to use seq to make it work. This version tested good on Fedora 11.
Stop tormenting the poor animal cat!
Also you should not that you need a private key not protected by a passphrase on middlehost that grants you access to securehost..
Debian: Mark all dependent packages as manually installed. So they are not automatically removed if you remove some meta package - like gnome-desktop-environment for example.
By using vim, you can also filter content on stdout, using vim's extra power, like search pattern offset!
No more awk of course, sorry.
-e ex mode
-c 'ex command' : global + start and end pattern + offset print (p)
-cq : quit
If you need to ssh into a computer on the local network but you're unsure of the ip to use, then ping them and see if you get a response. If you do, print out the address you got it from. Adjust the range to suit your network.
Nice little alarm clock to wake you up on time (hopefully).
You can also do 'echo "vlc path/to/song" | at 6:00
In the vein of "can you do it better", here is my take on using "ping" to emulate sleep in a DOS/BAT script. If one can use ping at all then the multicast address will be valid but will not respond. By doing only one ping (-n 1) and setting a timeout in milliseconds (-w 10000) you have a fairly accurate timer. This example gives about a 10 second sleep.
This is an extension of a previous command by satyavvd on 2009-07-23 12:04:02, but this one grabs the whole archive. Hard coded numbers in previous script capped number of commands that could be fetched. This one grabs them all regardless of how big the archive gets.
1. find file greater than 10 MB
2. direct it to xargs
3. xargs pass them as argument to ls
"&&" runs sed if and only if the backup completed and /bin/cp exited cleanly. Works for multiple files; just specify multiple filenames (or glob). Use -v switch for cp to play it safe.
this command works with one gziped file per table, and restore 4 tables in parallel.
this works on Solaris, so not better than the "only-GNU"-tool :-(
I think, there is no one-liner for this, that will work on all *nix-es
copy files to a ssh server with gzip compression