I need help from expert on this. How can I add @ at the first byte of the line after found matching pattern. For example as below :
Input:
TESTING 1234 0001 0002 0003
Output:
TESTING @1234 0001 0002 0003
Advertisement
Answer
You may execute the following sed script on the file:
sed -n '/TESTING/{p;n;s/^/@/;};p;' file
-n– don’t print output on default/TESTING/– if TESTING is matched{– thenp;– print output, ‘TESTING’n;– read next line, the line after TESTINGs/^/@/– substitude beginning of the line wiht @};p;– print output. This will print all non-matched lines with TESTING or will print the next line after TESTING witch substituted ‘@’