A file vik
sed '/keyword/ a\your-text-here' vik #insert your-text-here after every occurance of keyword
sed '5 a\your-text-here' vik #insert your-text-here at line 6
sed '5 i\your-text-here' vik #insert your-text-here at line 5
sed '/^keyword/ i\your-text-here' vik #insert your-text-here before keyword
sed '/^keyword/ c\your-text' vik #replace your keyword with your-text
sed '4 i\text1\ntext2' vik # this will insert two lines
sed and awk inserting new line
ReplyDelete[root@vikas Desktop]# echo "A B C D E F G H I J K L M N O P Q R S T U V W X Y Z" | awk 'BEGIN{n=1}{while(substr($0,n,16)){print substr($0,n,16);n+=16}}'
A B C D E F G H
I J K L M N O P
Q R S T U V W X
Y Z
[root@vikas Desktop]# echo "A B C D E F G H I J K L M N O P Q R S T U V W X Y Z" | sed -e "s/.\{16\}/&\n/g"
A B C D E F G H
I J K L M N O P
Q R S T U V W X
Y Z
[root@vikas Desktop]#