I need to print the data starting from the line that matches Data after AB process=1234 (full 10): till end of the file.

I tried putting the data in a variable called "value" and using sed as below. However, it gives an error "extra characters at the end of D command.

value="Data after AB process=1234 (full 10):"
sed -n ' '$value' ' p datasourcefile.log
sed -n '/Data after AB process=1234 (full 10):/,$p' file


value='Data after AB process=1234 (full 10):'
sed -n '/'"${value}"'/,$p' file

Take a look at: Difference between single and double quotes in bash

  • Thank you so much. I tried the second option and it worked – alex Jun 25 '15 at 19:54
{ grep -Fm1 'Data after AB process=1234 (full 10):'; cat; } <infile

...will work w/ a GNU grep and a regular input file.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.