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
for i in {1..40};do echo -n $i. $(date +%H:%M:%S):\ ; (time curl 'http://ya.ru/' &> /dev/null) 2>&1|grep real;sleep 1;done
2011-11-11 10:40:38
User: AntonyC
Functions: date echo grep sleep time
Tags: curl
-1

This uses curl to find out the access times of a web service

(echo -e '\xfe'; sleep 1) |telnet -L $HOSTIP 25565 2>/dev/null |awk -F'\xa7' '$2 {print "users: "$2"/"$3;}'
2011-11-07 02:28:03
User: Mozai
Functions: awk echo sleep telnet
1

I'm flat-out surprised that minecraft directory services require servers install multiple modifications to their server code, when the directories could fetch this information on their own.

#!/bin/bash cd /usr/share/consolefonts/; for i in * ; do setfont; echo "testing >> $i << font" ; setfont $i ; showconsolefont ; sleep 5 ; clear ; done
while true ; do echo -n "`date`";curl localhost:3000/site/sha;echo -e;sleep 1; done
2011-10-14 21:00:41
User: donnoman
Functions: echo sleep true
1

In this case it runs the command 'curl localhost:3000/site/sha' waiting the amount of time in sleep, ie: 1 second between runs, appending each run to the console.

This works well for any command where the output is less than your line width

This is unlike watch, because watch always clears the display.

while true ; do sleep 1 ; clear ; (netstat -tn | grep -P ':36089\s+\d') ; done
2011-09-28 11:39:43
User: hute37
Functions: clear grep netstat sleep true
-3

shell loop to scan netstat output avoiding loolback aliases (local/remote swap for local connections)

while true; do sleep 4 ; xdotool click 1 ; done
2011-09-23 09:23:02
User: rusino
Functions: sleep
-5

Automation click every 4 second on a macro slot bar to world of warcraft for prospecting item

enable auto loot and create macro, put mouse over slot on the bar

/cast Prospecting

/use Elementium Ore

i=60;while [ $i -gt 0 ];do if [ $i -gt 9 ];then printf "\b\b$i";else printf "\b\b $i";fi;sleep 1;i=`expr $i - 1`;done
while true; do xset dpms force off; sleep 0.3; xset dpms force on; xset s reset; sleep 0.3; done
2011-09-07 21:55:41
User: Escher
Functions: sleep
1

When aliens invade Earth, be first to warn your neighbours by placing your computer screen at a window and executing this potentially Earth-saving command.

Ctrl C when aliens are defeated.

say() { wget -q -U Mozilla -O output.mp3 "http://translate.google.com/translate_tts?tl=en&q=$1"; gnome-terminal -x bash -c "totem output.mp3"; sleep 4; totem --quit;}
2011-09-07 19:48:53
User: totti
Functions: bash sleep wget
1

No need to install additional packages

eg:

say hello

For multiword

say how+are+you

while sleep 30; do tput sc;tput cup 0 $(($(tput cols)-15));echo -n " New Emails: $(curl -u username:password --silent https://mail.google.com/mail/feed/atom | grep 'fullcount' | grep -o '[0-9]\+')";tput rc; done &
switchMonitor () { LF=/tmp/screen-lock; if [ -f $LF ]; then rm $LF; else touch $LF; sleep .5; while [ -f $LF ]; do xset dpms force off; sleep 2; done; fi };
2011-08-26 17:55:44
User: totti
Functions: rm sleep touch
1

Use the command to create a script and bind it to a key using keyboard shortcut.

eg:

Script locks the screen in a loop until the command is executed again.At first it

NotifyOnBATTERY () { while :; do on_ac_power||notify-send "Running on BATTERY"; sleep 1m; done }
2011-08-26 11:54:16
User: totti
Functions: sleep
Tags: battery notify
0

Works on Laptops, Desktop having communication b/w UPS & CPU

(sleep 3; echo "MyAwesomePassword"; sleep 3) |socat - EXEC:'ssh username@server "hostname"',pty,setsid,ctty
2011-08-24 14:13:18
User: TommyBotten
Functions: echo sleep
Tags: socat pts
-1

You should really use keys. Really. I'm serious.

But if you have to add your key, change password etc. for a long list of servers, this might help.

while notify-send "`acpi -t`"; do sleep 300; done
2011-07-05 18:22:06
Functions: sleep
1

Use acpi and notify-send to report current temperature every five minutes.

Works best in a shell script run at startup. acpi is called for temperature and fed to notify-send for a tooltip. After waiting five minutes, it will start over.

while ping -c 1 127.0.0.1 > /dev/null; do acpi -t -f | while read tem; do notify-send "$tem"; done; sleep 300; done
2011-07-02 06:47:25
User: c0de
Functions: acpi ping read sleep
2

works best in a shell script run at startup. It will ping localhost once and output to null, after it does that, acpi is called for temperature in fahrenheit and piped through to another loop that feeds notify-send for a tooltip. After waiting five minutes, it will start over.

while true; do sleep $(($RANDOM/1000)) && beep -f 2000 -l $(($RANDOM/100)) ; done
while true; do sleep $(($RANDOM/1000)) && beep -f 2000 -l $(($RANDOM/100)) ; done
dd if=/dev/urandom of=file.img bs=4KB& pid=$!; while [[ -d /proc/$pid ]]; do kill -USR1 $pid && sleep 1 && clear; done
2011-06-24 21:49:10
Functions: dd kill sleep
Tags: dd progress
2

Only slightly different than previous commands. The benefit is that your "watch" should die when the dd command has completed. (Of course this would depend on /proc being available)

var=host ;while ! nc -zw 1 $var 22;do sleep 1; done ; ssh user@$var
while true; do date; ssh <YOUR HOST HERE> "echo" && echo "HOST UP" && break; sleep 60; done
i=0;while :; do i=$(expr "$i" + 1); scrot "$i".png; sleep 2; done;
2011-05-27 00:25:28
User: scripteles
Functions: expr sleep
1

Take a screenshot every 2 seconds and save it as a png file

while sleep 1; do date; (netstat -a -n | grep 80) ; done
while true; do /bin/ping -q -c1 -w3 8.8.8.8 2>&1 > /dev/null || echo "8.8.8.8 ping failed at $(date +%d/%m/%y) $(date +%H:%M:%S)" >> /var/log/ping.log; sleep 10; done &
2011-05-12 01:51:07
User: Arkey
Functions: echo sleep
-1

This command are using by me for checking connection with Internet.

sleep 4h && halt
while true; do tput sc; tput cup 0 $(($(tput cols)-74)); w | grep load; tput rc; sleep 10; done &
2011-04-27 09:28:27
User: ahofmann
Functions: grep sleep tput
1

Gives not only date but also some interesting status about the System