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 yes

Commands using yes from sorted by
Terminal - Commands using yes - 25 results
yes | !!
2012-10-05 10:09:39
User: freck
Functions: yes
Tags: bash
1

I doubt this works with other than bash, but then again, I havent tried.

The 'yes' utility is very simple, it outputs a hell of a lot of 'y's to standard input.

The '!!' command means 'the last command'. So this one-lines inputs a lot of y's into the last command, aggressively agreeing to everything. For instance, when doing apt-get.

yes "" | cat -n | awk '{print "S=`echo All work and no play makes Jack a dull boy. | cut -c",($1 - 1) % 43 + 1 "`;echo -n \"$S\";seq 500000 > /dev/null"}'| bash
yes "$(seq 232 255;seq 254 -1 233)" | while read i; do printf "\x1b[48;5;${i}m\n"; sleep .01; done
yes 1 | fdupes -rd $folder
2011-06-02 18:15:24
User: torrid
Functions: yes
Tags: deduplicate
-1

This command deletes all but the first occurrence of a duplicate file in one or more folders.

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

taskset 0x00000001 yes > /dev/null &
2011-04-03 07:23:53
User: kerim
Functions: taskset yes
7

For each cpu set mask and then monitor your cpu infos. Temp,load avg. etc.

For example for 2nd cpu or 2nd core

taskset 0x00000002 yes > /dev/null &

For example for 3rd cpu or 3rd core

taskset 0x00000004 yes > /dev/null &

For example for 4th cpu or 4th core

taskset 0x00000008 yes > /dev/null &

Monitor your cpu temp with this command if you want

watch -n1 "acpi -t"

Load avg. from top command

top

kerim@bayner.com

http://www.bayner.com/

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
0

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.

yes "echo -ne '\r'\`date\`;sleep 1" | sh
yes n | cp something toSomeWhereElse
yes '' | head -n100
yes n | cp -p -i -r <src> <dest>
yes|for x in one two three; do echo result - $x; done
2010-06-01 14:49:29
User: Panikos
Functions: echo yes
-2

simple bash one liner to pass multiple arguments to command one by one. optional yes/no pipe at beginning of command

yes | pv | ssh $host "cat > /dev/null"
2009-12-27 21:34:23
User: opertinicy
Functions: ssh yes
Tags: ssh yes pv
22

connects to host via ssh and displays the live transfer speed, directing all transferred data to /dev/null

needs pv installed

Debian: 'apt-get install pv'

Fedora: 'yum install pv' (may need the 'extras' repository enabled)

yes "$(seq 1 255)" | while read i; do printf "\x1b[48;5;${i}m\n"; sleep .01; done
yes n
yes | tr 'y' 'n'
yes "$(seq 232 255;seq 254 -1 233)" | while read i; do printf "\x1b[48;5;${i}m\n"; sleep .01; done
yes '' | cat -n
xvidcap --file filename.mpeg --fps 15 --cap_geometry 1680x1050+0+0 --rescale 25 --time 200.0 --start_no 0 --continue yes --gui no --auto
2009-03-24 08:49:15
User: tristan_ph
Functions: yes
Tags: xvidcap compiz
4

That will capture 200 seconds of video at fullscreen 1680x1050 resolution, but scaled down 25 percent, with 15 frames per second.

http://fusioncast.blogspot.com/2007/09/infobyte-how-i-record-my-desktop.html

yes "text" | annoying_installer_program # "text" defaults to the letter y
yes 'Y'|gdb -ex 'p close(1)' -ex 'p creat("/tmp/output.txt",0600)' -ex 'q' -p pid
2009-02-20 17:36:57
User: adminzim
Functions: yes
7

This command uses the debugger to attach to a running process, and reassign a filehandle to a file.

The two commands executed in gdb are

p close(1) which closes STDOUT

and

p creat("/tmp/filename",0600)

which creates a file and opens it for output. Since file handles are assigned

sequentially, this command opens the file in place of STDOUT and once the process continues, new output to STDOUT will instead be written to our capture file.

yes "$(seq 232 255;seq 254 -1 233)" | while read i; do printf "\x1b[48;5;${i}m\n"; sleep .01; done