lundi 4 mai 2020

Replace a string only if the next line has another specific string

I am trying to replace a string on a line, only if the next line has a specific string.

I have:

13963   12602   gene
13963   12602   rRNA

And the result need be

13963   12602   rRNA
13963   12602   rRNA

Where the numbers vary... So I tried:

VAR_1=$1

if [grep rRNA -B1  $1 |awk '{print $3}' |head -n1 ='gene']
 then
   sed 's/gene/rRNA'
fi

And I get

line 5: [grep: command not found
head: =gene]: No such file or directory

And I don't quite know where to go from here...

Aucun commentaire:

Enregistrer un commentaire