Yes, I did it!

yes command outputs string repeatedly until killed. If string is not specified, it output "y".

The command is obsolete today. But it has been very useful in many situations.

I was searching what is the usage of yes command and I was quite astonished by it’s one of the usage which I will explain latter in this article.

Very first usage is sending affirmative or negative response to any command which runs in interactive mode.

For example,

$ rm *.txt ( This command will ask whether to delete each and every file that is a interactive mode )

If you don’t want to bother about this then

$ yes | rm *.txt

which is equivalent to

$ rm -f *.txt ( -f is force and it runs rm in non-interactive mode. But -f option is added to rm command quite late and before that yes was very helpful )

besides this, it is also very useful configure package or system which uses config files like linux-kernel. If you haven’t configured it and you want to enable all options then you can pipe yes to config command.

It is also useful in various testing like filesystem where you can generate large volume of files using this.

$ yes 12345 | head 10000 > file

One of the surprising usage which I was taking about is

yes command has been used to test capability of system or hardware. If you run yes command and see processor usage it is 100%. If you want to test if your processor is capable of handling high load then run yes. It has been used to test system’s cooling capacity.

Enjoy!

Post a Comment

You must be logged in to post a comment.
%d bloggers like this: