If the inputfile contains:
la1_22000
la1_22066
la1_22124
la1_22236
la1_22341
la1_22431
la1_22572
In order to remove the text between two lines which contains the keywords la1_22066 and la1_22431 respectively,
set keyword1 = la1_22066
set keyword2 = la1_22431
sed "s/$keyword1/,/$keyword2/d" inputfile
Attention: in order to use variables in SED, it is better to use double quote than single quote.
If we have special characters in the keyword, for example, /, what we can do is to add \ before it, such that the system can identify this special character.
Example: to repalce /aaa with /bbb
set 's/\/aaa/\/bbb/g' inputfile
Aucun commentaire:
Enregistrer un commentaire