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

Print the detailed statistics of transferred bytes by the firewall rules

AWK command to extract log files between dates

Massive change of file extension (bash)
Using bash parameters expansion

Recursively unrar into dir containing archive
From the cwd, recursively find all rar files, extracting each rar into the directory where it was found, rather than cwd. A nice time saver if you've used wget or similar to mirror something, where each sub dir contains an rar archive. Its likely this can be tuned to work with multi-part archives where all parts use ambiguous .rar extensions but I didn't test this. Perhaps unrar would handle this gracefully anyway?

Find files and list them sorted by modification time
This uses the ability of find (at least the one from GNU findutils that is shiped with most linux distros) to display change time as part of its output. No xargs needed.

Convert embedded spaces in filenames to "_" (underscore)
This command converts filenames with embedded spaces in the current directory replacing spaces with the underscore ("_") character.

Prepend a text to a file.
Using the sed -i (inline), you can replace the beginning of the first line of a file without redirecting the output to a temporary location.

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"

remove the last of all html files in a directory
sed can be used deleting the last line and with -i option, there's no need to for temp files, the change is made on the actual file

Search for a string inside all files in the current directory


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: