You need to use the -s
option:
$ cut -d ' ' -sf 2- <<< "example" $
By default, if a line has no delimiters, cut
will print the entire line. -s
turns this behavior off.
Not that your second example, does have a delimiter:
cut -d ' ' -f 2- <<< "example "
Because the line has a delimiter, cut
does what you expect.
Documentation
This behavior is documented in man cut
:
-f, --fields=LIST
select only these fields; also print any line that contains no delimiter character, unless the -s option is specified