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

Find out the starting directory of a script
Invoked from within a shell script, this will print the directory in which the script resides. Doesn't depend on external tools, /proc/self/*, etc.. (`echo` is a shell builtin.) To see the *current working* directory of a script, use `pwd`.

List folders containing only PNGs

Perpetual calendar
Gets any date since today. Other examples of recognized expressions are "2 years 4 days ago", "7 months" (in the future), "next Sunday", "yesterday", "tomorrow", etc.

Advanced python tracing
Trace python statement execution and syscalls invoked during that simultaneously

exec chmod to subfiles
Using `-exec cmd {} +` causes find to build the command using all matching filenames before execution, rather than once per file.

Windows telnet
Check if TCP port is reacheable

Recursively grep thorugh directory for string in file.
Print line numbers also, so you don't have to search through the files once its open for the string you already grepped for.

Join lines split with backslash at the end
Joins each line that end with backslash (common way to mark line continuation in many languages) with the following one while removing the backslash.

Make vim open in tabs by default (save to .profile)
I always add this to my .profile rc so I can do things like: "vim *.c" and the files are opened in tabs.

Print lines in a text file with numbers in first column higher or equal than a value
A text file contains thousands of numbers. This command prints lines were the number is greater or equal than a specified value (134000000).


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: