I want to extract some lines with
awk. Is it possible to do the following task:
ls -l | awk 'BEGIN FOR(i=122;i<=129;i++) FNR==i'
How can I display the details from line numbers 122 to 129?
You have not understood how
more compact method
Ths one give a range for
One more alternate method would be to use
But if, as your question suggests, it's important to use awk for this, go with manatwork's comment on Zrajm's answer. As awk's documentation states:
So if you want, you can also make more advanced conditions. For example:
This would start output at line 122, and continue until a line contained the word "foobar".
If you tell us the actual use case, we might be able to help with answers that provide a better solution. I'm worried that this sounds like an XY problem.
Another way of doing this (though I prefer the