Is there a Linux command similar to yes but one that outputs newlines? Something like

$ yes enter

That outputs


Similar too how yes 'foo' outputs

  • Sorry for some reason '<enter>' disappeared. The question is "Is there a linux command similar to 'yes' but one that outputs '<enter>'? – Jimbo May 10 '18 at 21:41
  • 2
    maybe..., yes enter? – iruvar May 10 '18 at 21:43
  • 1
    By <enter> do you mean the literal string <enter> or the carriage return? – Jesse_b May 10 '18 at 21:49
  • 1
    You can give yes an empty string argument i.e. yes '' - if you just want repeated newlines – steeldriver May 10 '18 at 22:06

Similar to what was mentioned in the comments, this will do it:

yes '<enter>'

Will output the literal string <enter>, or you can use '' for newlines.

yes ''
  • Thanks for the edit @EvanCarroll. I considered adding that as well but wasn't convinced that was what the OP wanted. – Timothy Martin May 10 '18 at 22:37
  • just tried in osx ~$ yes ''| cp -i a.a b.b and it said overwrite b.b? (y/n [n]) not overwritten – barlop May 24 at 15:28

Well, if yes '' wasn't good enough (and it is) but you just wanted to show off by being more esoteric you could always do

tr \\000 \\n < /dev/zero
  • In both senses, the answer to the question asked is yes. (-: – JdeBP May 11 '18 at 3:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.