I know how to use head
or tail
to output a certain number of lines, but how do I output only a specific line number(s)?
Something like:
head --only-line=73 <file>
head -n LINE_NUMBER file.txt | tail -n + LINE_NUMBER
where LINE_NUMBER
is which line number you want to print.
You can also use:
awk '{if(NR==LINE_NUMBER) print $0}' file.txt
Or
sed -n LINE_NUMBERp file.txt
Source: Write a bash script to print a particular line from a file - GeeksforGeeks
See Also:
head .. | tail ..
does seem a bit memory intensive. Perhaps on a fundamental level this is how any process can read the file.
Commented
Nov 8, 2023 at 10:03