My Tech Notes
Search This Blog
sed: insert or append line after matching line
Original text file: 1.txt:
abc def ghi
To insert line before line "abc":
sed -i '/^abc/ i 111' 1.txt
the result will be:
111 abc def ghi
To append line after line "abc":
sed -i '/^abc/ a 111' 1.txt
the result will be:
abc 111 def ghi
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment