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

Commands using yes from sorted by
Terminal - Commands using yes - 26 results
dsadd group cn=group_name,dc=example,dc=com -secgrp yes -scope g -samid group_name
2014-03-06 15:25:17
Functions: yes
Tags: windows group cmd
0

-secgrp no for distribution

-scope u for distribution

yes 'echo $(( RANDOM%100+1 )); sleep 5' | bash
2013-11-09 16:22:59
User: stx
Functions: sleep yes
0

This one is for OS X users: sort -R and shuf aren't available in Lion (10.7.5)

yes 'c=(" " " " " " 0 1); printf "${c[RANDOM%5]}"' | bash
svn ps svn:executable yes /web/itscripts/check_mail.plproperty
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
-2

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
8

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

[email protected]

http://www.bayner.com/

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
26

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.