if line 5 of a file needs to be replaced with contents of $line, how could we possibly do this using sed ?
kneiel
0
Newbie Poster
Recommended Answers
Jump to PostUse -i for in-place replacement and do this:
sk@sk:/tmp$ cat >> file << _EOF_ > line1 > line2 > line3 > line4 > line5 > _EOF_ sk@sk:/tmp$ sed -i '3 s/.*/Your Replacement Here/g' file sk@sk:/tmp$ cat file line1 line2 Your Replacement Here line4 line5 sk@sk:/tmp$
Notice the …
All 2 Replies
Reply to this topic
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.