0

Im trying to remove the following two lines:

<STREAMINFO> 1 39
<VECSIZE> 39<NULLD><MFCC_D_A_0><DIAGC>

which are repeated many times in a texfile (hmmdefs) in the folder hmm0.

How could I do that in UNUX?

Tried to remove each time separately, but when running the following command in command-line:

sed "<STREAMINFO> 1 39" hmm0/hmmdefs

I receive the following error:

sed: 1: "<STREAMINFO> 1 39": invalid command code <
Avinash Raj
  • 172,303
  • 28
  • 230
  • 274
KianStar
  • 177
  • 1
  • 9
  • possible duplicate of [Delete a line containing a specific string using sed](http://stackoverflow.com/questions/5410757/delete-a-line-containing-a-specific-string-using-sed) – chooban Jan 10 '15 at 12:20

1 Answers1

1

You need to use d flag to delete the line which was matched by the given regex. And don't forget to enclose the regex within the / delimiters.

sed "/<STREAMINFO> 1 39/d" hmm0/hmmdefs

To be more specific, you need to add anchors.

sed "/^<STREAMINFO> 1 39$/d" hmm0/hmmdefs

^ Asserts that we are at the start and $ asserts that we are at the end.

Example:

$ cat file
<STREAMINFO> 1 39
<VECSIZE> 39<NULLD><MFCC_D_A_0><DIAGC>
foo bar
$ sed '/<STREAMINFO> 1 39\|<VECSIZE> 39<NULLD><MFCC_D_A_0><DIAGC>/d' file
foo bar
Avinash Raj
  • 172,303
  • 28
  • 230
  • 274
  • I have another question, I tried to post it separately but it says I should wain 90 minutes... I have a file containing the string `"proto"` which is repeated 384 times. Each `"proto"` should be edited according to 384 different labels existing in another textfile. For insance, if the content of the second text file is `a, sp, ..` (each label exists in a newline), so in my textfile the first "proto" should be changed to `"a"`, the second to `"sp"` and so on. How should I do that? – KianStar Jan 10 '15 at 12:42
  • wait and ask it as a new question. – Avinash Raj Jan 10 '15 at 12:43