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

comment current line(put # at the beginning)

Find usb device in realtime
Using this command you can track a moment when usb device was attached.

Optimize Xsane PDFs
Xsane produces PDFs that are too large - particularly multipage PDFs. This command compresses them. If you do not use A4, remove the -sPAPERSIZE flag.

Battery real life energy vs predicted remaining plotted
This time I added a print to reemaining energy, every minute, time stamped. The example shown here is complete and point to large discrepancies as time passes, converging to accuracy near the end.

Convert any sequence of spaces/tabs to single space/tab
Remove empty lines additionally: $ tr -s ' \t\n' 2.txt identical with: $ tr -s '[:space:]' 2.txt To "clean perfectly" a text or code file, You can combine this command with another one: $ while read l; do echo -e "$l"; done 2.txt (= remove all leading and trailing spaces or tabs from all lines of a text file)

Generate map of your hardware

list block devices
Shows all block devices in a tree with descruptions of what they are.

Do a search-and-replace in a file after making a backup
sed already has an option for editing files in place and making backup copies of the old file. -i will edit a file in place and if you give it an argument, it will make a backup file using that string as an extension.

Convert CSV to JSON
Replace 'csv_file.csv' with your filename.

Stat each file in a directory
Possible simplification of egrep-awk-sort with find and -exec with xargs.


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: