0

I would like to cat the contents of a file that follows and includes the target line.

2014-06-23 11:01:01,001 dog  
2014-06-23 12:01:01,001 cat  
2014-06-23 13:01:01,001 elephant    
2014-06-23 14:01:01,001 bird  
2014-06-23 15:01:01,001 rabbit  
2014-06-23 16:01:01,001 deer  

I want to cat the line 2014-06-23 13:01:01,001 elephant and following lines by searching 2014-06-23 13:01:01,001

The desired output would be:

2014-06-23 13:01:01,001 elephant    
2014-06-23 14:01:01,001 bird  
2014-06-23 15:01:01,001 rabbit  
2014-06-23 16:01:01,001 deer  

Thank you in advance and I always welcome documentation links!

JSolano
  • 51
  • 1
  • 1
  • 8

1 Answers1

4

Using sed, you can print from the pattern 2014-06-23 13:01:01,001 to the end of the file, like this:

$ sed -n '/2014-06-23 13:01:01,001/,$p' file
2014-06-23 13:01:01,001 elephant
2014-06-23 14:01:01,001 bird
2014-06-23 15:01:01,001 rabbit
2014-06-23 16:01:01,001 deer
dogbane
  • 266,786
  • 75
  • 396
  • 414
  • *It worked on my machine* That was a typo, but I agree that I'll need to pass the variable to awk. Your solution is much more elegant. +1. – axiom Jun 23 '14 at 17:10