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.

Given a file of humongous size, I can edit with ed, then issue the following command.

g/real/p

Which will print out all lines containing 'real'.

What I want to do is print the first 20.

I know sed, grep, head, etc. But I want to improve my ed skills.

share|improve this question
    
I don't know ed, but | head -n20? –  Rob Feb 5 '13 at 18:35
1  
Hi, trying to find solution only using ed. –  Bryan Hunt Feb 5 '13 at 18:49
add comment

1 Answer

You can specify ranges before your commands in the form from,to.

1,4p

would print lines 1-4.

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.