Sign up ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

I want to use cut command to break input into fields and get the second field. cut -f2 -d' ' <--- How can I tell it to use tab instead of space

share|improve this question
Using cut with unprintable delimiters (stackoverflow) – nobar Nov 21 '14 at 20:14

4 Answers 4

up vote 86 down vote accepted

Two ways:

Press Ctrl-v + Tab

cut -f2 -d'   ' infile

or write it like this:

cut -f2 -d$'\t' infile
share|improve this answer
$'' — bash'ism, AFAIR – poige Mar 30 '12 at 11:45
Neither works in Windows (e.g., Git Bash) obviously. Use @Mikel's answer there (default delimiter is tab, simply omit -d argument). – Ahmed Fasih Nov 4 '14 at 14:40
@AhmedFasih, both work in Cygwin, though (tested) – Walter Tross Jun 17 at 17:16

Tab is the default.

See the cut man page.

-d delim
         Use delim as the field delimiter character instead of the tab

So you should just write

cut -f 2
share|improve this answer
Oops didn't notice that line. – Hasan Khan Mar 30 '12 at 15:54
But it is probably always safer to mention such flags explicitly, for both readability and portability. I can imagine some people designing a cut for Windows would not follow the complete standard. – CommuSoft Apr 19 at 12:32

awk '{ print $2; }' inputfile

share|improve this answer
That will fail if $1 contains spaces. Specify the field separator. – manatwork Mar 30 '12 at 11:32
If you wish to preserve other whitespace than \t, then it will fail. Otherwise not. – ipip Mar 30 '12 at 12:07
@ipip The question specifically mentions tabs instead of spaces. – Burhan Ali Mar 30 '12 at 13:04

More generically, without requiring any invisible characters: Use tr to convert the delimiters to a format that can be specified more easily to cut.

$ echo -e "a\tb\tc" |tr '\t' ' ' |cut -d' ' -f2

tr is a simple, but powerful, character matching and replacement tool.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.