Yes (Unix)
Encyclopedia
yes is a Unix
Unix
Unix is a multitasking, multi-user computer operating system originally developed in 1969 by a group of AT&T employees at Bell Labs, including Ken Thompson, Dennis Ritchie, Brian Kernighan, Douglas McIlroy, and Joe Ossanna...

 command, which outputs an affirmative response, or a user-defined string of text continuously until killed.

Description

By itself, the yes command outputs 'y' or whatever is specified as an argument, followed by a newline
Newline
In computing, a newline, also known as a line break or end-of-line marker, is a special character or sequence of characters signifying the end of a line of text. The name comes from the fact that the next character after the newline will appear on a new line—that is, on the next line below the...

 repeatedly until stopped by the user or otherwise killed
Kill (Unix)
In computing, kill is a command that is used in several popular operating systems to send signals to running processes, for example to request the termination of this process.-Unix and Unix-like:...

; when piped into a command, it will continue until the pipe breaks (i.e., the program completes its execution).

It can also be used to test how well a system handles high loads, as using yes results in 100% processor usage, for systems with a single processor (for a multiprocessor
Multiprocessor
Computer system having two or more processing units each sharing main memory and peripherals, in order to simultaneously process programs.Sometimes the term Multiprocessor is confused with the term Multiprocessing....

 system, a process must be run for each processor). This, for example, can be useful for investigating whether a system's cooling system will be effective when the processor is running at 100%.

Uses

yes can be used to send an affirmative (or negative; e.g. yes n) response to any command that would otherwise request one, thereby causing the command to run non-interactively.

This usage may be obsolete today, as most commands that would request response from the user have either a 'force' option (e.g., rm
Rm (Unix)
rm is a basic UNIX command used to remove objects such as files, directories, device nodes, symbolic links, and so on from the filesystem...

 -f
) or an 'assume-yes' option (e.g., apt-get
Advanced Packaging Tool
The Advanced Packaging Tool, or APT, is a free user interface that works with core libraries to handle the installation and removal of software on the Debian GNU/Linux distribution and its variants...

 -y
in Debian
Debian
Debian is a computer operating system composed of software packages released as free and open source software primarily under the GNU General Public License along with other free software licenses. Debian GNU/Linux, which includes the GNU OS tools and Linux kernel, is a popular and influential...

).

As an example, the following:

rm -f *.txt

is equivalent to

yes | rm *.txt

The yes command in conjunction with the head
Head (Unix)
head is a program on Unix and Unix-like systems used to display the first few lines of a text file or piped data. The command syntax is: head [options] <file_name>...

 command can be used to generate large volume files for means of testing. For example, executing

yes 1234567 | head -1000 > file

results in a file consisting of 1000 lines each consisting of eight characters (1, 2, 3, 4, 5, 6, 7 and newline).

In 2006, the yes command has received publicity for being a means to test whether or not a user's MacBook
MacBook
The MacBook was a brand of Macintosh notebook computers built by Apple Inc. First introduced in May 2006, it replaced the iBook and 12-inch PowerBook series of notebooks as a part of the Apple–Intel transition. Positioned as the low end of the MacBook family, the Apple MacBook was aimed at the...

 is affected by the Intermittent Shutdown Syndrome. By running the yes command twice via Terminal.app under Mac OS X
Mac OS X
Mac OS X is a series of Unix-based operating systems and graphical user interfaces developed, marketed, and sold by Apple Inc. Since 2002, has been included with all new Macintosh computer systems...

, users were able to max out their computer's CPU, and thus see if the failure was heat related.

External links

  • Manpage for yes (GNU
    GNU
    GNU is a Unix-like computer operating system developed by the GNU project, ultimately aiming to be a "complete Unix-compatible software system"...

    version)
The source of this article is wikipedia, the free encyclopedia.  The text of this article is licensed under the GFDL.
 
x
OK