I was told awk is great for working with columns of data. From what I have seen it's pretty cool, but I haven't found a good site that shows useful (to me) commands. What I'm looking for are the commands that print out lines 5-10 or lines 30-70. The closest I've found was

# Print the last line
      {line = $0}
  END {print line}

and that's not what I need. What I am also looking for is a command that would write lines 1-10 to a file, that would make analysis so much more palatable. if anyone here has any suggestions that would be wonderful, thank you so much.


-Al

Recommended Answers

All 2 Replies

I know this thread has gotten some view but no replies....does someone suggest I post this elsewhere so I can possibly get some help?

The awk internal variable NR tells you what line you are currently working on

awk 'NR > 4 && NR < 11' filename

O'Reilly book 'sed & awk' - the one with the the tarsiers on the front cover.
If you're going to use awk get that book.

If you're on Linux go to the gawk (GNU awk) user's guide -

http://www.delorie.com/gnu/docs/gawk/gawk_7.html

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.