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

A function to find the newest file in a directory

Creates a symbolic link or overwrites an existing one
-n: dereference the existing link -v: (optional) to be sure of what is being done -f: force the deletion of the existing one -s: creates a symlink Be careful: the destination can also be a file or a directory and it will be overwritten.

translate what is in the clipboard in english and write it to the terminal
Uses google api to translate, you can modify the language in which translate modifying the parameter "langpair=|en", the format is language input|language output.

Virtualbox rsync copy (without defining any virtualbox configuration)
That is, after running `vagrant ssh-config` to determine ports and ip's: $ vagrant ssh-config Host default HostName 127.0.0.1 User vagrant Port 2200 UserKnownHostsFile /dev/null StrictHostKeyChecking no PasswordAuthentication no IdentityFile /Users/romanvg/tmp/.vagrant/machines/default/virtualbox/private_key IdentitiesOnly yes LogLevel FATAL

Output requirements.txt packages pinned to latest version
Given a requirements.txt file with unpinned package names, output the packages pinned to the latest version. Handy to copy/paste back into your requirements.txt when you start a new project. Note that this will download packages but not install them.

Show drive names next to their full serial number (and disk info)

Convert seconds to [DD:][HH:]MM:SS
Converts any number of seconds into days, hours, minutes and seconds. sec2dhms() { declare -i SS="$1" D=$(( SS / 86400 )) H=$(( SS % 86400 / 3600 )) M=$(( SS % 3600 / 60 )) S=$(( SS % 60 )) [ "$D" -gt 0 ] && echo -n "${D}:" [ "$H" -gt 0 ] && printf "%02g:" "$H" printf "%02g:%02g\n" "$M" "$S" }

Monitor a file with tail with timestamps added

Jump to line X in file in Nano.
Starts the cursor on line X of file foo. Useful for longer files in which it takes a long time to scroll. If X is greater than the number of lines in file foo, it will go to the last existing line.

See system users


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: