0

I have to read a text file using shell scrip from value abc to pqr and store that data to new.txt

Note: text file contain multiple block of value abc to pqr. So I have to read all block one by one.

In linux I am searching a particular value from text file and I am getting text. i.e above and below 20 lines from the searched value. I am storing that data in new text file output.txt

Command:

Str=$(grep -i -B 20 -A 20 "searching_value" test.txt)
echo "${str}" >> output.txt
Bodo
  • 9,287
  • 1
  • 13
  • 29

0 Answers0