Skip to main content

Thread: sed expression question


good day everyone!
sorry ask how in sed "if 'string1' not exist add 'string2' end of file once"?
thank in advance!

use awk can keep counter/flag signify found.

code:
awk '/string1/{f=1}end{ if (!f) {print "string2"}}1' file
use best tool job.


Forum The Ubuntu Forum Community Ubuntu Specialised Support Development & Programming Programming Talk sed expression question


Ubuntu

Comments