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.

Universal configuration monitoring and system of record for IT.
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

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!
Hide

Top Tags

Hide

Functions

Hide

Credits

Commands using sleep from sorted by
Terminal - Commands using sleep - 250 results
while :; do OLD=$NEW; NEW=`cat /proc/net/dev | grep eth0 | tr -s ' ' | cut -d' ' -f "3 11"`; echo $NEW $OLD | awk '{printf("\rin: % 9.2g\t\tout: % 9.2g", ($1-$3)/1024, ($2-$4)/1024)}'; sleep 1; done
while [ /bin/true ]; do OLD=$NEW; NEW=`cat /proc/net/dev | grep eth0 | tr -s ' ' | cut -d' ' -f "3 11"`; echo $NEW $OLD | awk '{printf("\rin: % 9.2g\t\tout: % 9.2g", ($1-$3)/1024, ($2-$4)/1024)}'; sleep 1; done
2011-03-22 10:02:23
User: hons
Functions: awk cut echo grep sleep tr
15

Just a simple way without the need of additional tools. Of course, replace eth0 with your IF.

until (ssh root@10.1.1.39 2> /dev/null); do date; sleep 15; done
2011-03-08 08:42:12
User: greggster
Functions: sleep ssh
8

until (ssh root@10.1.1.39 2> /dev/null); do date; sleep 15; done

In this case will execute "date" then "sleep 15" until we are able to ssh into server, such as after a reboot

Could also be like:

until ( ping 10.1.1.39 1> /dev/null); do echo "server 10.1.1.39 is down"; sleep 15; done

MIN=10;for ((i=MIN*60;i>=0;i--));do echo -ne "\r$(date -d"0+$i sec" +%H:%M:%S)";sleep 1;done
2011-02-20 11:56:28
User: flatcap
Functions: echo sleep
11

Countdown clock - Counts down from $MIN minutes to zero.

I let the date command do the maths.

This version doesn't use seq.

MIN=10 && for i in $(seq $(($MIN*60)) -1 1); do printf "\r%02d:%02d:%02d" $((i/3600)) $(( (i/60)%60)) $((i%60)); sleep 1; done
while sleep 1;do tput sc;tput cup 0 $(($(tput cols)-29));date;tput rc;done &
2011-02-17 11:13:19
User: glaudiston
Functions: sleep tput
98

A nice way to use the console in full screen without forget the current time.

you can too add other infos like cpu and mem use.

yes 'clear;printf "`date`\n" | figlet -f starwars | boxes;sleep 1' | sh
2011-02-16 03:58:19
User: lkjoel
Functions: printf sleep yes
0

This is a different version from my original command: Console clock -- Beautiful (http://www.commandlinefu.com/commands/view/7902/console-clock-beautiful )

This one uses Boxes and Figlet.

To install the dependencies on Ubuntu, type in:

sudo apt-get install boxes figlet

To install the dependencies on Debian, type in:

aptitude install boxes figlet
yes 'clear;printf "\n\n`date`\n" | figlet -f starwars;sleep 1' | sh
2011-02-16 03:05:52
User: lkjoel
Functions: printf sleep yes
1

This will show a console clock with Figlet.

This is with the Star Wars font.

Change the -f option to anything else.

Notice: You need Figlet installed for this to work.

To install Figlet on Ubuntu, type in:

sudo apt-get install figlet

To install Figlet on Debian, type in:

aptitude install figlet
yes 'clear;printf "\n\n\n\n\t\t\t`date`\n";sleep 1' | sh
2011-02-16 02:57:16
User: lkjoel
Functions: printf sleep yes
2

This command will automatically clear the old clock time, and show the new clock time.

It will also slightly format it.

while sleep 1; do echo -n "\r`date`"; done
2011-02-15 23:48:37
User: nkoehring
Functions: echo sleep
1

Does the same but without a pipe and a new shell.

while $i;do `notify-send -t 200 "You are awesome :)"`;sleep 60; done;
2011-02-14 18:49:38
User: pahnin
Functions: sleep
-1

sends notification msg within repeated intervals of time to notify-send ;)

Just for fun.

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

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
while pkill -0 prog1; do sleep 10; done; prog2
pkill -0 prog1; while [ $? -eq 0 ]; do sleep 10; pkill -0 prog1; done; prog2
sleep 3600; amixer set Master mute
2011-02-06 03:14:33
User: kenbarbour
Functions: amixer set sleep
1

Mutes the speakers after an hour, in case you fall asleep watching a video...

while true; do curl -s http://whatthecommit.com | perl -p0e '($_)=m{<p>(.+?)</p>}s' | cowsay; sleep 2; done
while true; do lynx --dump http://whatthecommit.com/ | head -n 1 | cowsay; sleep 2; done
while sleep 1; do acpi -t | osd_cat -p bottom; done &
2011-01-14 23:22:57
User: linuts
Functions: acpi sleep
1

No need for a colon, and one less semicolon too. Also untested.

while :; do acpi -t | osd_cat -p bottom ; sleep 1; done &
2011-01-14 13:57:45
User: John_W
Functions: acpi sleep
3

There is no need for variables. I also added sleep to reduce cpu usage, however I didn't test it.

( for((i=0;$i<100;i++))do echo volume $i 1; sleep 0.1s; done; )| mplayer -slave -quiet sample.mp3
2011-01-06 11:22:03
User: Juluan
Functions: echo sleep
0

Of course, a fifo is required for piloting the fade out of another song, but with a few bash function, we can mix music in bash like :

crossfadeIn > mplayerfifo1 & crossfadeOut > mplayerfifo2

loop 0 10 > mplayer fifo1

etc etc

exipick -zi | while read x ; do exim -dM "$x"; sleep 1;done
2011-01-04 20:17:30
User: alustenberg
Functions: read sleep
Tags: exim
0

can also be invoked as 'exipick -zi | exim -dM' if you do not need/want the delay between flushes.

diff <(lsusb) <(sleep 3s && lsusb)
2010-12-27 22:46:54
User: Juluan
Functions: diff sleep
25

I often use it to find recently added ou removed device, or using find in /dev, or anything similar.

Just run the command, plug the device, and wait to see him and only him

for ((;;)) do pgrep wget ||shutdown -h now; sleep 5; done
dd if=/path/to/inputfile of=/path/to/outputfile & pid=$! && sleep X && while kill -USR1 $pid; do sleep X; done
2010-12-02 15:07:18
User: cyrusza
Functions: dd kill sleep
Tags: dd copy progress
2

Adjust "sleep X" to your needs.

*NOTE: First sleep is required because bash doesn't have a "post-test" syntax (do XXX while).

cat video.ogg | nc -l -p 4232 & wget http://users.bshellz.net/~bazza/?nombre=name -O - & sleep 10; mplayer http://users.bshellz.net/~bazza/datos/name.ogg