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 sleep from sorted by
Terminal - Commands using sleep - 234 results
say(){ mplayer -user-agent Mozilla "http://translate.google.com/translate_tts?tl=en&q=$(echo $* | sed 's#\ #\+#g')" > /dev/null 2>&1 ; }; sleep 3s && say "wake up, you bastard"
while true; do while [ `date +%H%M` == "1857" ] ; do sleep 1s; yes | head -n 2000 > /dev/dsp; done; done;
2011-04-23 14:44:26
User: mrwill
Functions: head sleep yes
-1

this command will beep like an alarm for one minute from 18:57. you can change "1857" to your desired time.

you should have alsa-oss package installed, and you should also be root or part of "audio" group.

sleep 3s && espeak "wake up, you bastard" 2>/dev/null
2011-04-20 07:21:45
User: javisol
Functions: sleep
13

I'd prefer this one, you have to install espeak to get this running

while :; do sensors|grep ^Core|while read x; do printf '% .23s\n' "$x"; done; sleep 1 && clear; done;
2011-04-20 06:41:57
Functions: grep printf read sleep
1

Watch the temperatures of your CPU cores in real time at the command line. Press CONTROL+C to end.

GORY DETAILS: Your computer needs to support sensors (many laptops, for example, do not). You'll need to install the lm-sensors package if it isn't already installed. And it helps to run the `sensors-detect` command to set up your sensor kernel modules first. At the very end of the sensors-detect interactive shell prompt, answer YES to add the new lines to the list of kernel modules loaded at boot.

sleep 15m; yes > /dev/dsp
2011-04-17 15:19:14
User: winemore
Functions: sleep yes
0

Just replace 15m with desired time. no suffix or 's' for seconds; 'h' for hours

You need to be root or in audio group to write to /dev/dsp.

You may use yes | head -n 2000 for about 1 second beep.

Wrote this as echo -e '\a' not always works as desired (ex. visual bell)

(sp-sc sop://broker.sopcast.com:3912/80562 8908 10999 &>/dev/null &); sleep 10; wait $(vlc http://localhost:10999); killall sp-sc
2011-04-06 00:08:38
User: Bonster
Functions: killall sleep wait
0

requires sp-auth installed

This command will auto kill sp-sc after vlc is closed, so u wont have to do it manually

while cat /proc/net/dev; do sleep 1; done | awk '/eth0/ {o1=n1; o2=n2; n1=$2; n2=$10; printf "in: %9.2f\t\tout: %9.2f\r", (n1-o1)/1024, (n2-o2)/1024}'
alias screensaver='for ((;;)); do echo -ne "\033[$((1+RANDOM%LINES));$((1+RANDOM%COLUMNS))H\033[$((RANDOM%2));3$((RANDOM%8))m$((RANDOM%10))"; sleep 0.1 ; done'
while [[ 1 ]] ; do clear; banner `date +%H:%M:%S` ; sleep 1; done
2011-03-24 16:41:09
User: lkj
Functions: banner sleep
Tags: bash clock
3

Turn your terminal into digital clock.

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
7

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
88

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