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 ascii from sorted by
Terminal - Commands tagged ascii - 31 results
for i in {1..256};do p=" $i";echo -e "${p: -3} \\0$(($i/64*100+$i%64/8*10+$i%8))";done|cat -t|column -c120
2014-04-04 16:54:53
User: AskApache
Functions: cat column echo

Prints out an ascii chart using builtin bash! Then formats using cat -t and column.

The best part is:

echo -e "${p: -3} \\0$(( $i/64*100 + $i%64/8*10 + $i%8 ))";

From: http://www.askapache.com/linux/ascii-codes-and-reference.html

echo -n text | hexdump -C
2014-02-21 09:15:15
User: Tomofumi
Functions: echo hexdump
Tags: sed hex ascii

hexdump could be used for conversion too!

wget -qO - http://www.asciiartfarts.com/random.cgi | sed -n '/<pre>/,/<\/pre>/p' | sed -n '/<table*/,/<\/table>/p' | sed '1d' | sed '$d' | recode html..ascii
alias html2ascii='lynx -force_html -stdin -dump -nolist'
man ascii
2012-01-26 20:39:13
User: titan2x
Functions: man

It shows the complete ascii table, and it works in BSD too, not only in Linux.

showkey -a
perl -e "binmode(STDOUT, ':utf8'); print \"$@\""; echo # newline
2012-01-02 10:34:51
User: mathias
Functions: echo perl

This is especially useful to get crazy stuff like space characters copied to your pasteboard correctly.

Source: https://github.com/mathiasbynens/dotfiles/blob/master/.functions

python -c 'print "hello".encode("hex")'
2011-12-13 23:05:17
User: atoponce
Functions: python

You can use "decode()" in a similar manner:

python -c 'print "68656c6c6f".decode("hex")'
xxd -p <<< <STRING>
files=(/usr/share/cowsay/cows/*); cowsay -f `echo ${files[$((RANDOM%${#files}))]}` `fortune` | toilet -F gay -f term
2011-02-20 05:55:33
User: lkjoel

This command will tell you your fortune, with a nice Ascii Art animal, and it is colorized

You need cowsay, toilet and fortune installed.

On Ubuntu this is:

sudo apt-get install cowsay toilet fortune


aptitude install cowsay toilet fortune
while [ 1 ]; do clear; echo 'YOUR TEXT HERE' | figlet -f banner -t | while IFS="\n" read l; do echo "$l"; sleep 0.01; done; done
2011-02-13 18:52:39
User: lkjoel
Functions: banner echo read sleep

Change YOUR TEXT HERE to the text you want.

On figlet -f banner, you can change it to any figlet font you have installed.

One variant for Star Wars fans could be this:

while [ 1 ]; do clear; echo 'Star Wars' | figlet -f starwars -t | while IFS="\n" read l; do echo "$l"; sleep 0.01; done; done

NOTICE: You need to install figlet.

On Ubuntu, this command is:

sudo apt-get install figlet

On Debian, this command is:

aptitude install figlet
cowsay -l | sed '1d;s/ /\n/g' | while read f; do cowsay -f $f $f;done
echo "text" | hd
echo -n "text" | od -A n -t x1 |sed 's/ /\\x/g'
2010-07-14 15:31:36
User: camocrazed
Functions: echo od sed
Tags: sed hex ascii od

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

echo "text" | od -t x1
2010-07-14 14:53:25
User: max_allan
Functions: echo od
Tags: perl hex ascii

Just use "od" and it can also dump in decimal or octal.

(use -t x1 and not just -x or it confuses the byte order)

There is a load of other formatting options, I'm not sure if you can turn off the address at the start of the line.

echo -n 'text' | perl -pe 's/(.)/sprintf("\\x%x", ord($1))/eg'
2010-07-14 12:20:42
User: putnamhill
Functions: echo perl
Tags: perl hex ascii

Here's a version that uses perl. If you'd like a trailing newline:

perl -pe 's/(.)/sprintf("\\x%x", ord($1))/eg; END {print "\n"}'
echo -n 'text' | xxd -ps | sed 's/[[:xdigit:]]\{2\}/\\x&/g'
2010-07-13 21:46:30
User: camocrazed
Functions: echo sed
Tags: sed hex ascii

Same as another one I saw, just with a cleaner sed command

Edit: updated the sed command to use the [[:xdigit:]] character class - more portable between locales

Note that it will have a newline inserted after every 32 characters of input, due to the output of xxd

figlet gunslinger_
echo -n 'text' | xxd -ps | sed -e ':a' -e 's/\([0-9]\{2\}\|^\)\([0-9]\{2\}\)/\1\\x\2/;ta'
2010-06-09 12:20:02
User: sata
Functions: echo sed
Tags: hex ascii

Converts the ascii text to hex from bash.

Check the sample output.

files=(/usr/share/cowsay/cows/*);cowsay -f `printf "%s\n" "${files[RANDOM % ${#files}]}"` "`fortune`"
2010-06-02 14:18:28
User: dog

Can be installed in the root crontab if you want it to update your motd.

If not on ubuntu you need to change /usr/share/cowsay/cows/* to the location of your cow 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'
while [ 1 ]; do banner 'ze missiles, zey are coming! ' | while IFS="\n" read l; do echo "$l"; sleep 0.01; done; done
2009-12-14 07:40:07
User: craigds
Functions: banner echo read sleep

Displays a scrolling banner which loops until you hit Ctrl-C to terminate it.

Make sure you finish your banner message with a space so it will loop nicely.

sed -r "s/\x1B\[([0-9]{1,3}((;[0-9]{1,3})*)?)?[m|K]//g
2009-11-03 00:34:06
User: vaejovis
Functions: sed

Removes ANSI color and end of line codes to the [{attr1};...;{attrn}m format.