Reputation: 103
I have not got any standard answer on how to use sed to replace a specific line with the line number.
May I know how to do that?
For example, I tried to replace line 45 using
sed -i '45s/*/T T F/' POSCAR
Not working...
Upvotes: 0
Views: 81
Reputation: 53478
You can use perl
for this job too.
perl -i '$. == 45 && $_ = "T T F\n"' POSCAR
(Assuming you want to replace all of line 45)
Upvotes: 0
Reputation: 88626
Add a dot:
Replace
sed -i '45s/*/T T F/' POSCAR
by
sed -i '45s/.*/T T F/' POSCAR
.
: match any character
*
: the preceding expression can match zero or more times
Upvotes: 2