I just discovered, to my dismay, the following part of the cut man page:
-f, --fields=LIST
select only these fields;
also print any line that contains no delimiter character, unless the -s option is specified
The -s option toggles the printing of lines with no delimiters.
In most cases, I would like lines with no delimiters to be considered as lines with a single field, so that:
$ echo "a" | cut -d' ' -f 1
would output a,
and
$ echo "a" | cut -d' ' -f 2
would output an empty line.
Is there an alternate version of cut where this is possible, or an option I don't know about?
As far as I understand, there is no option of cut that would return an empty line in the second case: if I use the -s option there is no line of output.
I can always use awk but in many cases this is not practical for me.