How can I create a file that contains everything after and including a particular search term from another file in the terminal?
Original file content: foo, bar, baz, qux
Search term: baz
New file content: baz, qux
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.Sign up to join this community
In the end I used pcregrep for this. The best usage I found for returning everything after the search term in a multiline file is the below, substituting for searchTerm, originalFile and newFile:
pcregrep -M 'searchTerm((.|\n)*)' originalFile > newfile