What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again.

Delete that bloated snippets file you've been using and share your personal repository with the world. 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.

Get involved!

You can sign-in using OpenID credentials, or register a traditional username and password.

First-time OpenID users will be automatically assigned a username which can be changed after signing in.

UpGuard checks and validates configurations for every major OS, network device, and cloud provider.

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:



May 19, 2015 - A Look At The New Commandlinefu
I've put together a short writeup on what kind of newness you can expect from the next iteration of clfu. Check it out here.
March 2, 2015 - New Management
I'm Jon, I'll be maintaining and improving clfu. Thanks to David for building such a great resource!

Top Tags



Commands tagged jpg from sorted by
Terminal - Commands tagged jpg - 12 results
jhead -rgt file-name.jpg
convert yourdoublewideimage.jpg -crop 50%x100% +repage output.jpg
2014-01-15 15:34:41
User: pagesix1536

Output should be two JPG files named like "output-1.jpg" and "output-2.jpg". The convert command is part of ImageMagick so you'll need that and dependent packages installed to use it.

for i in *.CR2; do dcraw -c -a -h $i | ppmtojpeg > `basename $i CR2`JPG; echo $i done; done
2013-07-25 14:58:15
User: optyler
Functions: echo

This command takes all CR2 files in the current directory and convert them into JPG

for file in *.jpg; do identify -format '%f %b %Q %w %h' $file; done
2012-11-16 10:06:35
User: phattmatt
Functions: file

Runs the identify command (from ImageMagick) on each jpg file in the current directory and returns image details according to the format parameter. The example here returns:

Filename FileSize Compression Width Height

More information about the available format options can be found here: http://www.imagemagick.org/script/escape.php

I usually redirect the output to a text file using "> listofdetails.txt" at the end. Spreadsheet magic can then be applied.

pdf2jpg(){ convert -density 400 -bordercolor white -border 0 -resize 992x1403 -quality 85 $1 ${1/%pdf/jpg} ; }
find . -type f -name '*.jpg' -exec convert -quality 75 {} {} \;
2011-09-23 13:51:18
User: bobby_tables
Functions: find

Requires ImageMagick to be installed.

This command was stolen from @climagic on Twitter.

Probably a duplicate of command below, but this command uses slightly higher quality.


rename 's/\.jpe?g$/.jpg/i' *
2010-11-14 21:22:13
User: icebrain
Functions: rename
Tags: rename jpg

the "i" controls case sensitiveness. It's slightly inefficient since it uselessly renames .jpg to .jpg, but that's more than compensated by launching only one process instead of two, besides being shorter to write.

rename 's/\.jpeg/\.jpg/' *.jpeg; rename 's/\.JPG/\.jpg/' *.JPG
convert in.pdf out.jpg
find . -iname "*.jpg" -print0 | tr '[A-Z]' '[a-z]' | xargs -0 cp --backup=numbered -dp -u --target-directory {location} &
2009-12-10 08:47:04
User: oracular
Functions: cp find tr xargs

Use if you have pictures all over the place and you want to copy them to a central location


Find jpg files

translate all file names to lowercase

backup existing, don't overwrite, preserve mode ownership and timestamps

copy to a central location

for f in *.flv; do ffmpeg -y -i "$f" -f image2 -ss 10 -vframes 1 -an "${f%.flv}.jpg"; done
2009-05-18 22:34:59
Tags: ffmpeg jpg flv

This is handy for making screenshots of all your videos for referring to in your flv player.

for i in *jpg; do jpeginfo -c $i | grep -E "WARNING|ERROR" | cut -d " " -f 1 | xargs -I '{}' find /mnt/sourcerep -name {} -type f -print0 | xargs -0 -I '{}' cp -f {} ./ ; done
2009-05-07 00:30:36
User: vincentp
Functions: cp cut find grep xargs

Find all corrupted jpeg in the current directory, find a file with the same name in a source directory hierarchy and copy it over the corrupted jpeg file.

Convenient to run on a large bunch of jpeg files copied from an unsure medium.

Needs the jpeginfo tool, found in the jpeginfo package (on debian at least).