I executed
cut -d '~' -f 2 on input
RSC
AED
FCB
A~RS
and I obtained
RSC
AED
FCB
RS
I realized that cut will return entire line if the delimiter does not exist. It is that true?
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.
Sign up to join this communityIt's true. POSIX define cut -f option as:
-f list
Cut based on a list of fields, assumed to be separated in the file by a delimiter character (see -d). Each selected field shall be output. Output fields shall be separated by a single occurrence of the field delimiter character. Lines with no field delimiters shall be passed through intact, unless -s is specified. It shall not be an error to select fields not present in the input line.
and this repeated again in -s
:
-s
Suppress lines with no delimiter characters, when used with the -f option. Unless specified, lines with no delimiters shall be passed through untouched.
cut -d '~' -f 2
at a prompt, type in some lines and see what gets printed.