Is there a \"canonical\" way of doing that? I\'ve been using head -n | tail -1
which does the trick, but I\'ve been wondering if there\'s a Bash tool that speci
Wow, all the possibilities!
Try this:
sed -n "${lineNum}p" $file
or one of these depending upon your version of Awk:
awk -vlineNum=$lineNum 'NR == lineNum {print $0}' $file
awk -v lineNum=4 '{if (NR == lineNum) {print $0}}' $file
awk '{if (NR == lineNum) {print $0}}' lineNum=$lineNum $file
(You may have to try the nawk
or gawk
command).
Is there a tool that only does the print that particular line? Not one of the standard tools. However, sed
is probably the closest and simplest to use.