`yes` in ubuntu

How to include hyphen or dash ( - ) character as argument yes in Ubuntu?

In FreeBSD, I can do this:

 $ yes "-tcp" | head -n 2 -tcp -tcp 

But on Ubuntu, I get an error:

 $ yes "-tcp" | head -n 2 yes: invalid option -- 't' Try `yes --help' for more information. 
+4
source share
3 answers

I think this will work:

 $ yes -- "-tcp" | head -n 2 

A double dash says yes to stop parsing options.

+11
source

Use yes -- -tcp . -- stop processing arguments.

 noufal@sanitarium % yes -- "-tcp" | head -n 2 -tcp -tcp 
+5
source

From info yes :

For output, an argument starting with -', precede it with -', for example, `yes - --help '

So you want:

 yes -- -tcp | head -n 2 
+4
source

Source: https://habr.com/ru/post/1385723/


All Articles