basak and homey,
Here is another way:
head -3 file.txt | tail -1
This captures the first 3 lines of file.txt
then displays only the last of these lines.
This approach can easily be modified to get a range of lines,
for example:
head -2 file.txt | tail -3
gives the third line and the lines directly before and after it (lines 2-4).
'head' and 'tail' are two simple utilities that are very useful when you do not need to do something more complicated with sed, awk, perl, etc. You might want to check out the man pages for both.
If you find another (and especially if you find a better) way, please post it here.
|