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

Use Perl like grep
If you've ever tried "grep -P" you know how terrible it is. Even the man page describes it as "highly experimental". This function will let you 'grep' pipes and files using Perl syntax for regular expressions. The first argument is the pattern, e.g. '/foo/'. The second argument is a filename (optional).

Get lines count of a list of files
This command gives you the number of lines of every file in the folder and its subfolders matching the search options specified in the find command. It also gives the total amount of lines of these files. The combination of print0 and files0-from options makes the whole command simple and efficient.

Listing today’s files only

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

Have your sound card call out elapsed time.
Useful contexts : You are doing yoga or some other physical training in which you are holding a position. Or you practice the pomodoro productivity technique. Or your girlfriend said "We're leaving in 40 minutes". Design details: sleep executes before espeak to give you a 5 seconds head start. espeak is run in the background so it doesn't mess up the timing.

find which of the zip files contains the file you're searching for
This command find which of your zip (or jar) files (when you have lots of them) contains a file you're searching for. It's useful when you have a lot of zip (or jar) files and need to know in which of them the file is archived. It's most common with .jar files when you have to know which of the .jar files contains the java class you need. To find in jar files, you must change "zip" to "jar" in the "find" command. The [internal file name] must be changed to the file name you're searching that is archived into one of the zip/jar files. Before run this command you must step into the directory that contains the zip or jar files.

recurisvely md5 all files in a tree
Found this little gem here: http://info.michael-simons.eu/2008/10/25/recursively-md5sum-all-files-in-a-directory-tree/

Remove a file whose name begins with a dash ( - ) character
Using the redundant ./ directory information prevents the dash from occurring at the beginning of the filename, and being interpreted as an option of the rm command. Also works using: $ rm -- -filename

Delete empty directories
Recursively delete empty directories. Use with care.

Netcat Relay
This is an example of using 3 hosts, in a netcat relay. first host connects to middle host 1 -> 2 Second hosts redirects to target host 1 -> 2 -> 3 I hope this makes sense.


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: