Say I want to go to the 80th last line of my file celery.log, but I don't know how many lines it has.
The equivalent of the tail command but go to the 80th line from the end instead of the default.
How would I do this?
Say I want to go to the 80th last line of my file celery.log, but I don't know how many lines it has.
The equivalent of the tail command but go to the 80th line from the end instead of the default.
How would I do this?
echo '$-79p' | ed -s celery.log
This would run the ed script $-79p on the file called celery.log, which would display the line that is 79 lines up from the last line of the file.
In a shell that understands here-strings:
ed -s celery.log <<<'$-79p'
If the file has less than 80 lines, ed will return an error (the character ? on its standard error stream) and produce no output on the standard output stream.
tail -n 80 celery.log | head -n 1
This will show the first of the last 80 lines (if the file has fewer than 80 lines, it will show the first line of the file).