0

I am doing a data monitoring and I am doing a cron job to get the data everyday. But I am receiving many junk data with my actual data that makes the file huge. For example my data is,

eg.hh.jk.ll.mm
ee.ff.gg.hh.uh
im.mi.jj.hh.ll
11.33.44.55.66

I have to print the data matching the line from ff.gg to the line matching 33.44. Line number is not available. So my result should be

ee.ff.gg.hh.uh
im.mi.jj.hh.ll
11.33.44.55.66

Thank you !

RajuBhai
  • 191

1 Answers1

1

Using sed:

sed -n '/ff\.gg/,/33\.44/p' file.log

The first // matches the starting pattern (line) and the last // matches the ending pattern (line).

Example:

$ cat file.txt                        
14.33.ad.55.66
eg.hh.jk.ll.mm
ee.ff.gg.hh.uh
im.mi.jj.hh.ll
11.33.44.55.66
1f.fs.45.55.66
11.as.56.55.66

$ sed -n '/ff\.gg/,/33\.44/p' file.txt
ee.ff.gg.hh.uh
im.mi.jj.hh.ll
11.33.44.55.66
heemayl
  • 56,300