Could you give me some advices about how to edit a file?
1
0
Entering edit mode
3.1 years ago
Riku ▴ 80

Hi, all.

I would like to edit the string "containing" status from the file as following.

before

Y43D4A.5b       WBGene00012791  status=Partially_confirmed
F27E5.1 WBGene00009192  asah-2
M04G12.4b       WBGene00010868  somi-1
M04G12.4b       WBGene00010868  somi-1
Y75B7AR.1       WBGene00022287  status=Confirmed

after

$ head after.file
Y43D4A.5b       WBGene00012791
F27E5.1 WBGene00009192  asah-2
M04G12.4b       WBGene00010868  somi-1
M04G12.4b       WBGene00010868  somi-1
Y75B7AR.1       WBGene00022287

Could you please some advices? Actually this file is very long, so I need operation by commands. I really appreciated your advices!

awk bash Linux • 784 views
ADD COMMENT
4
Entering edit mode
3.1 years ago

While this is not strictly bioinformatics-related, I'll give you a pass because it's a nice exercise in regex. You can use the tool sed for this for which you can read up on its usage. You could use sed 's/<PATTERN>/<REPLACEMENT>/'. The pattern you want to replace is basically "status" and all subsequent characters. The replacement will simply be nothing (or, if you don't want to end up with different numbers of fields for different rows, you could choose to replace it with "NA" or literally anything else).

sed 's/status.*//' might be a good start.

ADD COMMENT
0
Entering edit mode

I could edit my file! Thank you for your advices even though this question wasn't directly related to bioinformatics.

ADD REPLY

Login before adding your answer.

Traffic: 1399 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6