Insert new pattern in newline after the nth occurrence of a line pattern - Bash in Ubuntu 12.04

view story

http://www.unix.com – Hi, I am getting crazy after days on looking at it: Bash in Ubuntu 12.04.1 I want to do this: pattern="system /path1/file1 file1" new_pattern=" data /path2/file2 file2" file to edit: data.db - I need to search in the file data.db for the nth occurrence of pattern - pattern must match a complete line - insert after pattern a new line with new_pattern Sed in my installed Ubuntu does not seem to accept /c or /a commands, only -i !! So, I tried this: Code: sed "s%system /path1/file1 file1%&\n    data /path2/file2 file2%" -i data.db Which (HowTos)