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.

If you have a new feature suggestion or find a bug, please get in touch via http://commandlinefu.uservoice.com/

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.

Universal configuration monitoring and system of record for IT.

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 convert from sorted by
Terminal - Commands tagged convert - 78 results
convert -density 300 input.pdf -fill "rgb(255,255,255)" -opaque "rgb(0,0,0)" output.pdf
2010-10-07 17:24:19
User: akrog
Tags: pdf print convert

The pdf is first converted to a bitmap, so change "-density" to match your printer resolution. Also be careful about the RAM required.

In this example rgb(0,0,0) is replaced by rgb(255,255,255), change to suit your needs.

for file in *.jpg; do convert "$file" -resize 800000@ -quality 80 "small.$file"; done
2010-09-13 19:06:14
User: grinob
Functions: file
Tags: xargs convert

Convert all jpegs in the current directory into ~1024*768 pixels and ~ 150 KBytes jpegs

ls *.JPG | cut -d . -f 1 | xargs -L1 -i convert -resize 684 {}.JPG {}.jpg
recode -l |less
2010-08-19 17:35:23
User: vlan7
Tags: convert

aliases on each line.



recode ..HTML <file.txt >file.html

txt to Base64:

recode ../b64 <file.txt >file.b64

and so on.

find . -type f -iname '*.flac' | while read FILE; do FILENAME="${FILE%.*}"; flac -cd "$FILE" | lame -b 192 - "${FILENAME}.mp3"; done
2010-08-15 19:02:19
User: paulochf
Functions: find read

find . -type f -iname '*.flac' # searches from the current folder recursively for .flac audio files

| # the output (a .flac audio files with relative path from ./ ) is piped to

while read FILE; do FILENAME="${FILE%.*}"; flac -cd "$FILE" | lame -b 192 - "${FILENAME}.mp3"; done

# for each line on the list:

# FILE gets the file with .flac extension and relative path

# FILENAME gets FILE without the .flac extension

# run flac for that FILE with output piped to lame conversion to mp3 using 192Kb bitrate

convert example.png -resize 100x100! output.png
2010-08-08 17:29:36
User: karpoke
Tags: convert

Adding the exclamation mark to the image geometry ignores the original aspect ratio.

More info about image geometry:


convert example.png -resize 100x100 output.png
2010-08-08 16:40:21
User: dbbolton

You can also specify width and height of the resized image (in pixels), as an alternative to using a percentage.

convert -quality 40% original_image reduced_image
utime(){ python -c "import time; print(time.strftime('%a %b %d %H:%M:%S %Y', time.localtime($1)))"; }
utime(){ awk -v d=$1 'BEGIN{print strftime("%a %b %d %H:%M:%S %Y", d)}'; }
utime(){ date -d "1970-01-01 GMT $1 seconds"; }
utime { date -d @$1; }
2010-05-12 12:21:15
User: deltaray
Functions: date

More recent versions of the date command finally have the ability to decode the unix epoch time into a human readable date. This function makes it simple to utilize this feature quickly.

ffmpeg -i input.avi -s qcif -vcodec h263 -r 20 -b 180k -acodec libfaac -ab 64k -ac 2 -ar 22050 output.3gp
2010-04-24 23:01:21
User: mariusbutuc


-i = input file name

-s = set frame size, qcif=176x144

-vcodec = force video codec

-r = frame-rate [default = 25]

-b = bit-rate [200 kb/s]

-acodec = force audio codec

-ab = audio bitrate in bits/s [64k]

-ac = no. of audio channels [1]

-ar = audio sampling frequency [44100 Hz]


-sameq = use same video quality as source (implies VBR)

-f = force format

-y = overwrite output files

echo $ascii | perl -ne 'printf "%x", ord for split //'
echo $ascii | perl -ne 'printf ("%x", ord($1)) while(/(.)/g); print "\n";'
echo $hex | perl -pe 's/(..)/chr(hex($1))/ge'
pv -cN orig < foo.tar.bz2 | bzcat | pv -cN bzcat | gzip -9 | pv -cN gzip > foo.tar.gz
2010-04-16 05:21:10
User: rkulla
Functions: gzip

In this example we convert a .tar.bz2 file to a .tar.gz file.

If you don't have Pipe Viewer, you'll have to download it via apt-get install pv, etc.

for file in *.flac; do flac -cd "$file" | lame -q 0 --vbr-new -V 0 - "${file%.flac}.mp3"; done
convert in.pdf out.jpg
utime(){ perl -e "print localtime($1).\"\n\"";}
2009-11-06 12:58:10
User: MoHaG
Functions: perl

A shell function using perl to easily convert Unix-time to text.

Put in in your ~/.bashrc or equivalent.

Tested on Linux / Solaris Bourne, bash and zsh. using perl 5.6 and higher.

(Does not require GNU date like some other commands)

ffmpeg -i input.mov -b 4096k -vcodec msmpeg4v2 -acodec pcm_u8 output.avi
2009-10-21 05:44:31
User: oracular

Convert those .mov files that your digital camera makes to .avi

Adjust the bitrate (-b) to get the appropriate file size. A larger bitrate produces a larger (higher quality) .avi file and smaller bitrate produces a smaller (lower quality) .avi file.

Requires ffmpeg (see man page for details)

(tested with canon camera MOV files)

Other examples:

ffmpeg -i input.mov -sameq -vcodec msmpeg4v2 -acodec pcm_u8 output.avi ffmpeg -i input.mov -b 1024k -vcodec msmpeg4v2 -acodec pcm_u8 output.avi
chr () { echo -en "\0$(printf %x $1)"}
chr() { printf \\$(printf %o $1); }
chr () { printf \\$(($1/64*100+$1%64/8*10+$1%8)); }
2009-10-15 07:01:54
User: dennisw
Functions: printf

I've corrected the function. My octal conversion formula was completely wrong. Thanks to pgas at http://mywiki.wooledge.org/BashFAQ/071 for setting me straight. The new function is from pgas and is very fast.

ffmpeg -i inputfile.mp4 outputfile.flv
2009-09-10 14:49:14
Tags: ffmpeg convert

This converts any media ffmpeg handles to flash. It would actually convert anything to anything, it's based on the file extension. It doesn't do ANY quality control, sizing, etc, it just does what it thinks is best. I needed an flv for testing, and this spits one out easily.