Which Linux command or utility is simple, powerful, and surprisingly unknown to many people or used less often?
This could be a command or a piece of software or an application.
For example I’m surprised to find that many people are unaware of Caddy, a very simple web server that can make setting up a reverse proxy incredibly easy.
Another example is fzf. Many people overlook this, a fast command-line fuzzy finder. It’s versatile for searching files, directories, or even shell history with minimal effort.
yes
The most positive command you’ll ever use.
Run it normally and it just spams ‘y’ from the keyboard. But when one of the commands above is piped to it, then it will respond with ‘y’. Not every command has a true -y to automate acceptance of prompts and that’s what this is for.
Also, you can make
yes
return anything:yes no
I… did not know that. Thanks, TIL!
What’s the syntax here? Do I go
I’m not sure if I’ve had a use case for it, but it’s interesting.
Also my favourite way to push a core to 100% CPU
yes > /dev/null
how is that better than
cat /dev/zero > /dev/null
or
while true; do :; done
Who said it was better? It’s just my favourite.
Like my favourite shirt, it’s no better than the others, but it brings me a little joy :)
That will just wait for
command
to finish properly and then runyes
.What you want to run is
yes | command
, so it spams the command with confirmations.true
delivers error level 0,false
error level 1.yes && echo True || echo False
will always be True.false && echo True || echo False
will always be False.Common usage is for tools that ask for permissions and similiar.
yes | cp -i
has the same effect ascp --force
(-i: prompt before overwrites).Sorry, I should have explained that. it’s
command | yesyes|command
- Eg,yes|apt-get update
(Not a great example since apt-get has -y, but sometimes that fails when prompting for new keys to accept)Edit: I got it backwards, thanks @lengau@midwest.social for the correction.
You’ve got it backwards - you need to pipe the output of
yes
into the input of the command:So I did - thanks for the correction, edited.
For some cases I use “|| true”.
The idiom accepts that the preceding command might fail, and that’s OK.
For example, a script where mkdir creates a directory that might already exist.
mkdir -p
will not complain if the dir existsRight, it was an example of a pattern. In that case, -p could be used.
I figured as much. Just wanted to show another option.