I could edit my file! Thank you for your advices even though this question wasn't directly related to bioinformatics.
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!
1 answer
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.
Log in to answer this question.