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 using seq from sorted by
Terminal - Commands using seq - 85 results
for y in $(seq 2009 2011); do cal $y; done
2009-07-10 10:07:46
Functions: cal seq
Tags: bash seq cal
3

print multiple increasing years using cal - calendar -. You can also try

seq Start Increment End
for i in $(seq 1 11) 13 14 15 16; do man iso-8859-$i; done
2009-03-31 19:40:15
User: penpen
Functions: man seq
Tags: Linux unix
-2

Depending on the installation only certain of these man pages are installed. 12 is left out on purpose because ISO/IEC 8859-12 does not exist. To also access those manpages that are not installed use opera (or any other browser that supports all the character sets involved) to display online versions of the manpages hosted at kernel.org:

for i in $(seq 1 11) 13 14 15 16; do opera http://www.kernel.org/doc/man-pages/online/pages/man7/iso_8859-$i.7.html; done
seq 0 0.1 20 | awk '{print $1, cos(0.5*$1)*sin(5*$1)}' | graph -T X
2009-03-24 21:46:59
User: kaan
Functions: awk seq
2

The arguments of "seq" indicate the starting value, step size, and the end value of the x-range. "awk" outputs (x, f(x)) pairs and pipes them to "graph", which is part of the "plotutils" package.

seq 6 | awk '{for(x=1; x<=5; x++) {printf ("%f ", rand())}; printf ("\n")}'
2009-03-24 21:33:38
User: kaan
Functions: awk printf seq
Tags: awk seq
3

Displays six rows and five columns of random numbers between 0 and 1. If you need only one column, you can dispense with the "for" loop.

seq 50| awk 'BEGIN {a=1; b=1} {print a; c=a+b; a=b; b=c}'
2009-03-24 20:39:24
User: kaan
Functions: awk seq
Tags: awk seq
13

Another combination of seq and awk. Not very efficient, but sufficiently quick.

seq 100 | awk '{sum+=$1} END {print sum}'
2009-03-24 20:30:40
User: kaan
Functions: awk seq
Tags: awk seq
4

"seq 100" outputs 1,2,..,100, separated by newlines. awk adds them up and displays the sum.

"seq 1 2 11" outputs 1,3,..,11.

Variations:

1+3+...+(2n-1) = n^2

seq 1 2 19 | awk '{sum+=$1} END {print sum}' # displays 100

1/2 + 1/4 + ... = 1

seq 10 | awk '{sum+=1/(2**$1)} END {print sum}' # displays 0.999023
for i in $(seq 0 5) ; do echo "5 - $i" | bc -l ; sleep 60 ; done && echo "bye, bye" && shutdown -h now
2009-03-13 12:16:35
User: arctarus
Functions: bc echo seq shutdown sleep
-14

command to turn off your computer when you go home and can not wait

for ip in $(seq 1 25); do ping -c 1 192.168.0.$ip>/dev/null; [ $? -eq 0 ] && echo "192.168.0.$ip UP" || : ; done
2009-02-11 14:57:34
Functions: echo ping seq
0

this is very useful when there is a different network host to determine which are turned on or not

for i in $(seq 1 50) ; do echo Iteration $i ; done
2009-02-08 23:03:31
User: abcde
Functions: echo seq
8

Optionally, one can use {1..50} instead of seq. E.g. for i in {1..50} ; do echo Iteration $i ; done

seq -f"ftp://ftp.vim.org/pub/vim/patches/7.1/7.1.%03g" 176 240 | xargs -I {} wget -c {};
2009-02-06 03:19:06
User: liupeng
Functions: seq wget xargs
3

Seq allows you to define printf like formating by specified with -f, %03g is actually tells seq I got three digits, fill the blank digits with 0, and the range is from 176 to 240.