0

i want to extract content between two matching pattern from file . first both matching pattern store in variable and then give range to commands in variable .                     

but sed and awk both commands nothing giving in return .

startline="AWS_Scheduling_Services_Daily - Starting entry [S3_configuration]"
stopline="AWS_Scheduling_Services_Daily - Finished job entry [S3_configuration]"
awk '/'"$startline"'/,/'"$stopline"'/' job_file.txt
sed -n '/$start/,/$stop/p' job_file.txt
Danish
  • 257
  • 2
  • 12
  • 2
    Variables from shell to awk: https://stackoverflow.com/questions/19075671/how-do-i-use-shell-variables-in-an-awk-script , about patterns: https://stackoverflow.com/questions/38972736/how-to-print-lines-between-two-patterns-inclusive-or-exclusive-in-sed-awk-or about formatting code in messages: https://meta.stackexchange.com/questions/22186/how-do-i-format-my-code-blocks and how to ask a question: https://stackoverflow.com/help/how-to-ask – James Brown Oct 30 '19 at 11:11
  • Does this answer your question(I recently given this solution, if this doesn't help you, please edit your question as per James sir's provided links and let us know then)? [Substituting shell variables into awk pattern looking scanning through file](https://stackoverflow.com/questions/58600762/substituting-shell-variables-into-awk-pattern-looking-scanning-through-file) – RavinderSingh13 Oct 30 '19 at 11:19
  • error is gone.. issue was that special character came in matching pattern . that's why given error .. – Danish Oct 31 '19 at 13:55

0 Answers0