Another.Chemist
Another.Chemist

Reputation: 2559

Introduce character at specific line number

Good day to all,

Today, I was wondering how to introduce a character at the end of specific line.

Intial line: (The number corresponds to the line number. But, it is not part of the file)

...
101 ...
102 a,b,c,d
103 ...
...

Line what I want:

...
101 ...
102 a,b,c,d,
103 ...
...

Thanks in advance for any clue

Upvotes: 1

Views: 59

Answers (2)

Mark Setchell
Mark Setchell

Reputation: 207670

I think you want this:

sed '102s/$/fred/' file

That says "on line 102 replace the end of line with the word fred"

Upvotes: 6

Jotne
Jotne

Reputation: 41460

Using awk

awk 'NR==102 {$0=$0","}1' file

This will add , at end of line 102

Upvotes: 6

Related Questions