Add string into certain lines - sed

Hello all,

I have surely an easy question - but at the moment I do not see the solution.

All what I want is to add the string "/9201" within a file when a line starts with ":47A:".

This is how a file look like:

Information Tool
 :12:Delimiter
 :3:Space
 :47A:0329
 :3:Space

After the Substitution it should look like:

Information Tool
 :12:Delimiter
 :3:Space
 :47A:0329/9201
 :3:Space

What I tried so far is:

sed 's/\(^:47A.*\)/\1\/9201/g' <file>

Tx for your help.

sed '/^ *:47A/s/$/\/9201/' infile
1 Like

@rdrtx1: When I will do it in this way I will get the same result as with my command:

Information Tool
 :12:Delimiter
 :3:Space
/92010329
 :3:Space

By the way - there is no space before the ":". That is the code-tag... :frowning:

---------- Post updated at 05:31 PM ---------- Previous update was at 05:03 PM ----------

@rdrtx1: I did another Trial. I copied the Content of the file into another file and did the next Trial on this new file.
And now it works. The reason is: there is something wrong with my original file. I will have a look into the hex structure.
So, thanks for your help - nevertheless.