I know that this my be really simple, but I'm having a hard time accomplishing it. I am trying to add a new line of text after finding a particular string of text in a file. Here's what I'm getting:
sed: command garbled: N/search_string/\\new_text/
I was using "N" to add a line after the text. TIA.
You could also use awk, which I find gives you a bit more control than sed in these situations
awk '{ if ( $0 ~ /searchstring/ ) {
printf( "%s\n%s\n", "Some new inserted text here", $0 );
# could use the following to append
# printf( "%s\n%s\n", $0, "Some new appended text here" );
} else {
print $0;
}
}' my_input_file