Commands using sort (800)

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

Selecting a random file/folder of a folder
Also looks in subfolders

Share your terminal session (remotely or whatever)
Force the user you want to watch doing things into doing his things in a screen session. Then simply attach yourself to that session with the command shown above. Works only if you are on the same machine, of course

Nginx - print all optional modules before compilation
wget http://nginx.org/download/nginx-1.15.3.tar.gz && tar -xzf 1.15.3.tar.gz && cd nginx-1.15.3

Getting information about model no. of computer
This command gives a model information of a computer. Also useful in determining the host is a VM machine or actual physical machine.

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

Find the package that installed a command

create pdf files from text files or stdout.

Remove spaces from filenames - through a whole directory tree.
Sometimes, you don't want to just replace the spaces in the current folder, but through the whole folder tree - such as your whole music collection, perhaps. Or maybe you want to do some other renaming operation throughout a tree - this command's useful for that, too. To rename stuff through a whole directory tree, you might expect this to work: for a in `find . -name '* *'`;do mv -i "$a" ${a// /_};done No such luck. The "for" command will split its parameters on spaces unless the spaces are escaped, so given a file "foo bar", the above would not try to move the file "foo bar" to "foo_bar" but rather the file "foo" to "foo", and the file "bar" to "bar". Instead, find's -execdir and -depth arguments need to be used, to set a variable to the filename, and rename files within the directory before we rename the directory. It has to be -execdir and won't work with just -exec - that would try to rename "foo bar/baz quux" to "foo_bar/baz_quux" in one step, rather than going into "foo bar/", changing "baz quux" to "baz_quux", then stepping out and changing "foo bar/" into "foo_bar/". To rename just files, or just directories, you can put "-type f" or "-type d" after the "-depth" param. You could probably safely replace the "mv" part of the line with a "rename" command, like rename 'y/ /_/' *, but I haven't tried, since that's way less portable.

beep when a server goes offline
pings a server once per second, and beeps when the server is unreachable. Basically the opposite of: $ ping -a server-or-ip.com which would beep when a server IS reachable. You could also substitute beep with any command, which makes this a powerful alternative to ping -a: $ while true; do [ "$(ping -c1W1w1 server-or-ip.com 2>/dev/null | awk '/received/ {print $4}')" = 1 ] && date || echo 'server is down!'; sleep 1; done which would output the date and time every sec until the ping failed, in which case it would echo. Notes: Requires beep package. May need to run as root (beep uses the system speaker) Tested on Ubuntu which doesn't have beep out of the box... $ sudo apt-get install beep

Get your commandlinefu points (upvotes - downvotes)
This will calculate the your commandlinefu votes (upvotes - downvotes). Hopefully this will boost my commandlinefu points.


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: