How to insert text in multiple lines in vi editor
Posted By Steve Soe
In the vi editor, if you want to add the text before some keywords in the multiple lines, you can use this awk script.
For example: I have this file name called “/root/temp” and I want to add the word “sddl” in front of the words “Device: -r”. I wrote my awk script like this:
awk ‘ {
if ($0 ~ /^\sddl/)
print “Device:-r”$0
else
print $0} ‘ /root/temp
If you run the script, you will see the output and then you can redirect the output to a new file.
