All commands (14,187)

What's this?

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.

Share Your Commands


Check These Out

Backup all MySQL Databases to individual files

Backup all starred repositories from Github

Sort files by date
Show you the list of files of current directory sorted by date youngest to oldest, remove the 'r' if you want it in the otherway.

Press Any Key to Continue

Get your bash scripts to handle options (-h, --help etc) and spit out auto-formatted help or man page when asked!!
This will make your bash scripts better!! process-getopt is a wrapper around getopt(1) for bash that lets you define command line options (eg -h, --help) and descriptions through a single function call. These definitions are then used in runtime processing of command line options as well as in generating help and man pages. It also saves a little time in coding and in producing nicely formatted documentation. It is quite similar to GNU's argp in glibc for compiled languages and OptionParse for python. See: Linux Gazette article 162: http://tldp.org/LDP/LGNET/162/hepple.html, http://sourceforge.net/projects/process-getopt, http://bhepple.freeshell.org/oddmuse/wiki.cgi/process-getopt

Schedule a script or command in x num hours, silently run in the background even if logged out
This is helpful for shell scripts, I use it in my custom php install script to schedule to delete the build files in 3 hours, as the php install script is completely automated and is made to run slow. Does require at, which some environments without crontab still do have. You can add as many commands to the at you want. Here's how I delete them in case the script gets killed. (trapped) atq |awk '{print $1}'|xargs -iJ atrm J &>/dev/null

Insert a line for each n lines
specially usefull for sql scripts with insert / update statements, to add a commit command after n statements executed.

delete at start of each line until character
GNU grep's PCRE(Perl-compatible regular expressions).

list files recursively by size

Create a new file


Stay in the loop…

Follow the Tweets.

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

Subscribe to the feeds.

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: