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:
That is, after running `vagrant ssh-config` to determine ports and ip's:
lc Old_Directory New_DIrectory Old_Format New_Format
lc ~/Music ~/Music_ogg mp3 ogg
This will convert all files in the old directory to the new directory from the old format to the new format. It will leave the original library alone. The converted library will retain folder structure.
get the size of S3 bucket
Looks best in an 80x24 256-color terminal emulator.
Print a git log (in reverse order) giving a reference relative to HEAD.
HEAD (the current revision) can also be referred to as HEAD~0
The previous revision is HEAD~1 then HEAD~2 etc.
Add line numbers to the git output, starting at zero:
... | nl -v0 | ...
Insert the string 'HEAD~' before the number using sed:
... | sed 's/^ \+/&HEAD~/'
Thanks to bartonski for the idea :-)
This is a good alternative to pdf2text for Ubuntu. To install it:
sudo apt-get install python-pdfminer
pretty self explanitory
This version works on OS X (if you have installed `rename`)
shell order of operation example which calculates:
x = number of physical CPU's
y = number of cores per CPU
2(x * y) + 1 = CPU load limit
seed the random number generator,
find all matches in a file
put all matches from the capture group into an array
return a random element from the array
The only command-line version of this task I could come up with that properly handles UTF-8 input, too. (Yes, I know how crazy it is to have UTF-8 with HTML entity escapes, but that stuff exists... sadly...; Just check Twitter.)
Returns the current price of a troy ounce of gold, in USD. Requires the "jq" JSON parser.
Hold 'Ctrl' + 'Alt' key while selecting rectangular text area of the screen with
left mouse button.
Should work in any terminal screen (xterm, konsole, ...) under X, if not
then try with 'Ctrl' + 'Shift' + 'Alt' or two-combination of these.
I often have to google this so I put it here for quick reference.
In Thunderbird open the settings for your email account, mark the checkbox for 'Attach the signature from a file instead' and use the filename '~/mailsignature.txt'
Now every time when you open a terminal you see the fortune displayed in the terminal and the mail signature gets regenerated.
See "Parameter Expansion" in the bash manpage. They refer to this as "Use Alternate Value", but we're including the var in the at alternative.
The read command reads input and puts it into a variable. With -i you set an initial value. In this case I used a known environment variable.