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

Most simple way to get a list of open ports

Copy files from multiple directories into one directory

quick and dirty formatting for HTML code
Finds all the closing tags in a HTML document via non-greedy regex and adds a linefeed for easier reading/editing . sed -i.bak -r 's_(/[^>]*?>)_\1\n_g' filename.html . This will save a copy of filename.html as filename.html.bak and then add the linefeeds to the original file

add a gpg key to aptitute package manager in a ubuntu system
when we add a new package to a aptitude (the debian package manager) we need to add the gpg, otherwise it will show warning / error for missing key

Prints per-line contribution per author for a GIT repository
Uses line-porcelain in git blame, which makes it easier to parse the output.

Retrieve a random command from the commandlinefu.com API
Can be integrated into your .bashrc if you like. You'll probably want to grep out my name.

Big Countdown Clock in seconds
Requires figlet. Other than that, this should be portable enough across all the Bourne-compatible shells (sh, bash, ksh, zsh, etc). Produces a massive number using figlet that counts down the number of seconds for any given minute interval. For example, here's a 4-minute timer: $ i=$((4*60)); while [ $i -gt 0 ]; do clear; echo $i | figlet; sleep 1; i=$(($i-1)); done; And a 1-minute timer: $ i=$((1*60)); while [ $i -gt 0 ]; do clear; echo $i | figlet; sleep 1; i=$(($i-1)); done;

Determine what an process is actually doing

Sort lines using the Xth characted as the start of the sort string
Tells sort to ignore all characters before the Xth position in the first field per line. If you have a list of items one per line and want to ignore the first two characters for sorting purposes, you would type "sort -k1.3". Change the "1" to change the field being sorted. The decimal value is the offset in the specified field to sort by.

enumerate with padding
bash2 : for X in $(seq 1 5); do printf "%03g " "$X";done bash3 : for X in {1..5}; do printf "%03g " "$X";done bash4 : echo {001..5}


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: