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

Sort by IP address

Rename all .jpeg and .JPG files to .jpg

convert a,b,c to ('a','b','c') for use in SQL in-clauses

create ICO file with more than one image
requires imagemagick. -background transparent is of course optional.

backup your history
simple and easy backup your history with timestamp

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"

recursive search and replace old with new string, inside files
If you can install rpl it's simpler to use and faster than combinations of find, grep and sed. See man rpl for various options. time on above operation: real 0m0.862s, user 0m0.548s, sys 0m0.180s using find + sed: real 0m3.546s, user 0m1.752s, sys 0m1.580s

Print every Nth line
Sometimes commands give you too much feedback. Perhaps 1/100th might be enough. If so, every() is for you. $ my_verbose_command | every 100 will print every 100th line of output. Specifically, it will print lines 100, 200, 300, etc If you use a negative argument it will print the *first* of a block, $ my_verbose_command | every -100 It will print lines 1, 101, 201, 301, etc The function wraps up this useful sed snippet: $ ... | sed -n '0~100p' don't print anything by default $ sed -n starting at line 0, then every hundred lines ( ~100 ) print. $ '0~100p' There's also some bash magic to test if the number is negative: we want character 0, length 1, of variable N. $ ${N:0:1} If it *is* negative, strip off the first character ${N:1} is character 1 onwards (second actual character).

Create a tar file with the current date in the name.
Same, but count of signs is little less :) .

Partition a sequence of disk drives for LVM with fdisk
So, I'm using a CentOS VM in VirtualBox, and created four new disks in the SCSI controller. The VM created the folders: /dev/sda /dev/sdb /dev/sdc /dev/sdd Using a 'for loop' all disks are partitioned for LVM.


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: