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 top to monitor only all processes with the same name fragment 'foo'
top accecpts a comma separated list of PIDs.

Replace all forward slashes with backward slashes
Use -i option to edit directly a file: sed -i 's|\/|\\|g' file

regex for turning a URL into a real hyperlink (i.e. for posting somewhere that accepts basic html)
This should work with anything://url.whatever etc etc ;)

Get a docker container's run command line
A good way to build a new container when you don't remember how you did it the first time

Search for classes in Java JAR files.

Write a shell script that removes files that contain a string
Deletes files in the current directory or its subdirectories that match "regexp" but handle directories, newlines, spaces, and other funky characters better than the original #13315. Also uses grep's "-q" to be quiet and quit at the first match, making this much faster. No need for awk either.

Backup files incremental with rsync to a NTFS-Partition
This will backup the _contents_ of /media/SOURCE to /media/TARGET where TARGET is formatted with ntfs. The --modify-window lets rsync ignore the less accurate timestamps of NTFS.

List the Sizes of Folders and Directories
I wanted an easy way to list out the sizes of directories and all of the contents of those directories recursively.

Which processes are listening on a specific port (e.g. port 80)
swap out "80" for your port of interest. Can use port number or named ports e.g. "http"

Convert ascii string to hex
Here's a version that uses perl. If you'd like a trailing newline: $ perl -pe 's/(.)/sprintf("\\x%x", ord($1))/eg; END {print "\n"}'


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: