bash – How to Define ‘Tab’ Delimiter with ‘Cut’ Command

bashcut

Here is an example of using cut to break input into fields using a space delimiter, and obtaining the second field:

cut -f2 -d' '

How can the delimiter be defined as a tab, instead of a space?

Best Answer

Two ways:

Press Ctrl+V and then Tab to use "verbatim" quoted insert.

cut -f2 -d'   ' infile

or write it like this to use ANSI-C quoting:

cut -f2 -d$'\t' infile
Related Question