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

Create thumbnails and a HTML page for listing them (with links to sources)
The input images are assume to have the "JPG" extension. Mogrify will overwrite any gif images with the same name! Will not work with names with spaces.

generate file list modified since last commit and export to tar file
################################################################################ # get all modified files since last commit and zip them to upload to live server ################################################################################ # delete previous tar output file rm mytarfile.tar -rf #rm c:/tarOutput/*.* -rf # get last commit id and store in variable declare RESULT=$(git log --format="%H" | head -n1) # generate file list and export to tar file git diff-tree -r --no-commit-id --name-only --diff-filter=ACMRT $RESULT | xargs tar -rf mytarfile.tar # extract tar files to specified location tar -xf mytarfile.tar -C c:/tarOutput

Summarise the size of all files matching a simple regex
Use the find command to match certain files and summarise their total size in KBytes.

Create a tar archive using 7z compression
Using 7z to create archives is OK, but when you use tar, you preserve all file-specific information such as ownership, perms, etc. If that's important to you, this is a better way to do it.

Find usb device in realtime
Using this command you can track a moment when usb device was attached.

list files recursively by size

share internet connection with only one network interface
the below command create a alias for share your internet connection with another. $ifconfig eth0:1 192.168.0.1/24 Its obviously necessary too activate the iptables post-routing and ip forwarding, as root: $modprobe iptable_nat $iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE $echo 1 > /proc/sys/net/ipv4/ip_forward Be sure that the alias 192.168.0.0/24 is not your active real ip range

Show git branches by date - useful for showing active branches
Print out list of all branches with last commit date to the branch, including relative time since commit and color coding.

Remove last line from files recursively
Used this command recently to remove the trailing ?> from all the files in a php project, which has having some unnecessary whitespace issues. Obviously, change *.php to whatever you'd like.

Convert ascii string to hex
If you're going to use od, here's how to suppress the labels at the beginning. Also, it doesn't output the \x, hence the sed command at the end. Remove it for space separated hex values instead


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: