Reputation: 1182
I want to use bash to process a tab delimited file. I only need the second column and third to a new file.
Upvotes: 42
Views: 55564
Reputation: 161
expanding on the answer of carl-norum, using only tab as a delimiter, not all blanks:
cut -d$'\t' -f 2-3 input.txt > output.txt
don't put a space between d and $
Upvotes: 3
Reputation: 45672
Cut is probably the best choice here, second to that is awk
awk -F"\t" '{print $2 "\t" $3}' input > out
Upvotes: 15
Reputation: 225032
cut(1)
was made expressly for this purpose:
cut -f 2-3 input.txt > output.txt
Upvotes: 86