简体   繁体   中英

Sed substitution with back reference not working

I receive output from a program as tab separated values, of which I am trying to obtain the second only using sed. I am currently using this:

sed -r -e "s/(^[^\t]+\t)([^\t]+\t)(.*$)/\2/"

However it does not seem to find matches. I have tried it in rubular were it does give me the match I want.

在此处输入图片说明

There is a specialized tool for selecting columns from text files called cut:

cut -f2 file

Here we instruct it to select only the second column, see the manpage for more information. Tab is the default column separator.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM