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

Remove several files with ease
Rather than typing out all 10 files, you can use brace expansion to do the trick for you. This is useful for backup files, numbered files, or any files with a repeating pattern. Gives more control than 'rm file*' as I might want to keep others around.

Download file with multiple simultaneous connections
jrk's aria2 example is incorrect. -s specifies the global connection limit; the per-host connection limit is specified with -x.

Functions to display, save and restore $IFS
You can display, save and restore the value of $IFS using conventional Bash commands, but these functions, which you can add to your ~/.bashrc file make it really easy. To display $IFS use the function ifs shown above. In the sample output, you can see that it displays the characters and their hexadecimal equivalent. This function saves it in a variable called $saveIFS: $ sifs () { saveIFS=$IFS; } Use this function to restore it $ rifs () { IFS=$saveIFS; } Add this line in your ~/.bashrc file to save a readonly copy of $IFS: $ declare -r roIFS=$IFS Use this function to restore that one to $IFS $ rrifs () { IFS=$roIFS; }

Archive all SVN repositories in platform indepenent form
This command dumps all SVN repositories inside of folder "repMainPath" (not recursively) to the folder "dumpPath", where one dump file will be created for each SVN repository.

Undo commit in Mercurial

Quick way to sum every numbers in a file written line by line
If you have a file full of numbers written line by line, you can sum every line to get the total. With a file like this: 3443535 9878977 67554 987798 232324 you will got: 14610188

Get each users commit amount

Get AWS temporary credentials ready to export based on a MFA virtual appliance
You might want to secure your AWS operations requiring to use a MFA token. But then to use API or tools, you need to pass credentials generated with a MFA token. This commands asks you for the MFA code and retrieves these credentials using AWS Cli. To print the exports, you can use: `awk '{ print "export AWS_ACCESS_KEY_ID=\"" $1 "\"\n" "export AWS_SECRET_ACCESS_KEY=\"" $2 "\"\n" "export AWS_SESSION_TOKEN=\"" $3 "\"" }'` You must adapt the command line to include: * $MFA_IDis ARN of the virtual MFA or serial number of the physical one * TTL for the credentials

Recursive grep of all c++ source under the current directory
I like this better than some of the alternatives using -exec, because if I want to change the string, it's right there at the end of the command line. That means less editing effort and more time to drink coffee.

ssh -A user@somehost
the -A argument forwards your ssh private keys to the host you're going to. Useful in some scenarios where you have to hop to one server, and then login to another using a private key.


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: