Hide

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.

Hide

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:

Hide

News

2011-03-12 - Confoo 2011 presentation
Slides are available from the commandlinefu presentation at Confoo 2011: http://presentations.codeinthehole.com/confoo2011/
2011-01-04 - Moderation now required for new commands
To try and put and end to the spamming, new commands require moderation before they will appear on the site.
2010-12-27 - Apologies for not banning the trolls sooner
Have been away from the interwebs over Christmas. Will be more vigilant henceforth.
2010-09-24 - OAuth and pagination problems fixed
Apologies for the delay in getting Twitter's OAuth supported. Annoying pagination gremlin also fixed.
Hide

Tags

Hide

Functions

Commands tagged fortune from sorted by
Terminal - Commands tagged fortune - 11 results
fortune | cowsay $(ls/usr/share/cowsay | shuf -n1)
2014-10-23 10:09:44
0

To install on centos 6.2

for Centos auto accept:

yum install fortune* -y

yum install cowsay* -y

Removed the -f command as I dont know how, but it works without it.

Almost the same but one folder higher =).

echo 'Dir.foreach("/usr/local/Cellar/cowsay/3.03/share/cows") {|cow| puts cow; system "fortune | cowsay -f /usr/local/Cellar/cowsay/3.03/share/cows/#{cow}" }' | ruby
2013-04-15 12:27:38
User: orkoden
Functions: echo
-1

Shows a list of all installed cows saying a fortune. Also lists the cows names. Pic your favorite cow!

Needs cowsay, fortune and ruby installed. The path only applies to OS X with cowsay installed using homebrew. On Linux it might be /usr/share/cowsay/cows/ or similar. Uses ruby just because.

curl -s http://smacie.com/randomizer/borat.html | sed -nE "s# *<td valign=\"top\"><big><big><big><font face=\"Comic Sans MS\">(.*)</font></big></big></big></td>#\1#p"
2012-07-18 21:31:43
User: phymata
Functions: sed
1

I improved a bit on the original by only using sed and extracting the quote with a matching group.

Use -nE for sed on Mac OSX

Use -nr for sed on Linux.

Warning! The quotes from Borat are definitely offensive.

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
-1

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

Debian:

aptitude install cowsay toilet fortune
fortune | cowsay -f $(ls /usr/share/cowsay/cows/ | shuf -n1)
2010-07-08 02:57:52
User: zed
Functions: ls
8

You need to have fortune and cowsay installed. It uses a subshell to list cow files in you cow directory (this folder is default for debian based systems, others might use another folder).

you can add it to your .bashrc file to have it great you with something interesting every time you start a new session.

cowsay `fortune` | toilet --metal -f term
2010-06-03 21:48:54
-6

Get colorful fortunes dictated by an ASCII cow. For full enjoyment you'll need to have color setup enabled for your terminal.

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

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.

fortune | cowsay -f tux
fortune | cowsay
cowsay $(fortune)
curl -s http://bash.org/?random1|grep -oE "<p class=\"quote\">.*</p>.*</p>"|grep -oE "<p class=\"qt.*?</p>"|sed -e 's/<\/p>/\n/g' -e 's/<p class=\"qt\">//g' -e 's/<p class=\"qt\">//g'|perl -ne 'use HTML::Entities;print decode_entities($_),"\n"'|head -1
2009-05-07 13:13:21
User: Iftah
Functions: grep head perl sed
7

bash.org is a collection of funny quotes from IRC.

WARNING: some of the quotes contain "adult" jokes... may be embarrassing if your boss sees them...

Thanks to Chen for the idea and initial version!

This script downloads a page with random quotes, filters the html to retrieve just one liners quotes and outputs the first one.

Just barely under the required 255 chars :)

Improvment:

You can replace the head -1 at the end by:

awk 'length($0)>0 {printf( $0 "\n%%\n" )}' > bash_quotes.txt

which will separate the quotes with a "%" and place it in the file.

and then:

strfile bash_quotes.txt

which will make the file ready for the fortune command

and then you can:

fortune bash_quotes.txt

which will give you a random quote from those in the downloaded file.

I download a file periodically and then use the fortune in .bashrc so I see a funny quote every time I open a terminal.