开发者

How can I get 2nd and third column in tab delim file in bash?

开发者 https://www.devze.com 2023-03-12 17:01 出处:网络
I want to use bash to pr开发者_Python百科ocess a tab delimited file. I only need the second column and third to a new file.cut(1) was made expressly for this purpose:

I want to use bash to pr开发者_Python百科ocess a tab delimited file. I only need the second column and third to a new file.


cut(1) was made expressly for this purpose:

cut -f 2-3 input.txt > output.txt


Cut is probably the best choice here, second to that is awk

awk -F"\t" '{print $2 "\t" $3}' input > out


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 $

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号