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 all mail in Postfix mail queue.

a simple bash one-liner to create php file and call php function

delete all leading and trailing whitespace from each line in file

command line calculator
simple function , floating point number is supported.

python - covert image to base64 string for data URI use
useful if you are using lots of data URI's in your css files

Join lines and separate with spaces
Read vmargs.txt, which is a text file that could either be DOS-style (\r\n) or UNIX-style (\n) line endings and join the lines with a space separator. Can this be shortened/made more elegant?

Download an entire website
-p parameter tells wget to include all files, including images. -e robots=off you don't want wget to obey by the robots.txt file -U mozilla as your browsers identity. --random-wait to let wget chose a random number of seconds to wait, avoid get into black list. Other Useful wget Parameters: --limit-rate=20k limits the rate at which it downloads files. -b continues wget after logging out. -o $HOME/wget_log.txt logs the output

Ask for a password, the passwd-style
You can ask repeatedly for a non-blank password using this function: function read_password() { while [ ! -n "$USER_PASSWORD" ]; do read -s -p"Password: " USER_PASSWORD if [ ! -n "$USER_PASSWORD" ]; then echo "ERROR: You must specify a valid password, please try again" fi echo done } Also you can set a time out (in seconds) to write the password read -t 10 -s -p"Password: " USER_PASSWORD_VARIABLE if [ ! $? -eq 0 ]; then echo "Time out!" fi

Command to rename multiple file in one go
An entirely shell-based solution (should work on any bourne-style shell), more portable on relying on the rename command, the exact nature of which varies from distro to distro.

Determine space taken by files of certain type
Just how much space are those zillions of database logs taking up ? How much will you gain on a compression rate of say 80% ? This little line gives you a good start for your calculations.


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: