Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have a file with a similar format...

16:28 asdfasdf
16:29 4398upte
16:30 34liuthr
16:31 34tertio

How can I use SED to print out every line including and after the line with "16:30"?

The result would be...

16:30 34liuthr
16:31 34tertio

Right now, I am using sed as follows, but I have to manually find the first line's line number e.g. "562697":

sed -n '562697,$p'
share|improve this question
add comment

2 Answers

up vote 6 down vote accepted

Addresses in sed can be either line numbers or patterns. Try this:

sed -n '/16:30/,$p'

If the pattern contains a /, you can escape it with a \. For example, to search for 16/30 instead of 16:30, try this:

sed -n '/16\/30/,$p'
share|improve this answer
    
What if I needed to search 16/30? I'm not sure how to modify the syntax in this case. Thanks! –  barrrista Mar 7 '13 at 0:01
    
@barrrista I've edited my answer to show how to escape the character with a backslash. Hope this helps. –  Nicole Hamilton Mar 7 '13 at 0:12
add comment

Use a regular expression in the address:

sed -n '/^16:30/,$p'

or

sed '/^16:30/,$!d'
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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