I need to find the first substring in a (text)file, drop/cut leading bytes, write remaining bytes to a new file. I tried SED,AWK,CUT but got so lost in not so good results. Sounds a simple task to do. This should work in .sh cmdline script.
Input file may have newlines or everything is in a single line, so to find <?xml
marker should work character or byte level. Leading bytes are random and any length.
Input file:
something I want to drop<?xml............to the end of file</root>
Output file: <?xml............to the end of file</root>
sed -n '/.*<?xml/,${s//<?xml/;p}' file
From xml line to end line ($
), strip leading, then print.
-n
doesn't print unless p
tells it to print the pattern buffer.//
in the replacement will match the previous match string, in this case /.*<?xml/