Go to line of file where number of lines minus ânâ [duplicate]
Clash Royale CLAN TAG#URR8PPP
up vote
0
down vote
favorite
This question already has an answer here:
Display only the penultimate (second last) row of a text [duplicate]
5 answers
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?
command-line terminal
marked as duplicate by Kusalananda, ñÃÂsýù÷, Jeff Schaller, SatÃ
 Katsura, Kiwy May 9 at 7:42
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
add a comment |Â
up vote
0
down vote
favorite
This question already has an answer here:
Display only the penultimate (second last) row of a text [duplicate]
5 answers
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?
command-line terminal
marked as duplicate by Kusalananda, ñÃÂsýù÷, Jeff Schaller, SatÃ
 Katsura, Kiwy May 9 at 7:42
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
2
What do you mean by "go to"?
â Kusalananda
May 8 at 7:26
The equivilant oftail
command but go to the 80th last line instead of the default.
â Zorgan
May 8 at 7:27
4
liketail -n80 celery.log
?
â Charles
May 8 at 7:29
@Charles yes that's perfect. thanks!
â Zorgan
May 8 at 8:26
add a comment |Â
up vote
0
down vote
favorite
up vote
0
down vote
favorite
This question already has an answer here:
Display only the penultimate (second last) row of a text [duplicate]
5 answers
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?
command-line terminal
This question already has an answer here:
Display only the penultimate (second last) row of a text [duplicate]
5 answers
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?
This question already has an answer here:
Display only the penultimate (second last) row of a text [duplicate]
5 answers
command-line terminal
edited May 8 at 7:43
roaima
39.4k544105
39.4k544105
asked May 8 at 7:20
Zorgan
1104
1104
marked as duplicate by Kusalananda, ñÃÂsýù÷, Jeff Schaller, SatÃ
 Katsura, Kiwy May 9 at 7:42
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
marked as duplicate by Kusalananda, ñÃÂsýù÷, Jeff Schaller, SatÃ
 Katsura, Kiwy May 9 at 7:42
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
2
What do you mean by "go to"?
â Kusalananda
May 8 at 7:26
The equivilant oftail
command but go to the 80th last line instead of the default.
â Zorgan
May 8 at 7:27
4
liketail -n80 celery.log
?
â Charles
May 8 at 7:29
@Charles yes that's perfect. thanks!
â Zorgan
May 8 at 8:26
add a comment |Â
2
What do you mean by "go to"?
â Kusalananda
May 8 at 7:26
The equivilant oftail
command but go to the 80th last line instead of the default.
â Zorgan
May 8 at 7:27
4
liketail -n80 celery.log
?
â Charles
May 8 at 7:29
@Charles yes that's perfect. thanks!
â Zorgan
May 8 at 8:26
2
2
What do you mean by "go to"?
â Kusalananda
May 8 at 7:26
What do you mean by "go to"?
â Kusalananda
May 8 at 7:26
The equivilant of
tail
command but go to the 80th last line instead of the default.â Zorgan
May 8 at 7:27
The equivilant of
tail
command but go to the 80th last line instead of the default.â Zorgan
May 8 at 7:27
4
4
like
tail -n80 celery.log
?â Charles
May 8 at 7:29
like
tail -n80 celery.log
?â Charles
May 8 at 7:29
@Charles yes that's perfect. thanks!
â Zorgan
May 8 at 8:26
@Charles yes that's perfect. thanks!
â Zorgan
May 8 at 8:26
add a comment |Â
3 Answers
3
active
oldest
votes
up vote
3
down vote
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.
add a comment |Â
up vote
2
down vote
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).
add a comment |Â
up vote
1
down vote
Yo can do this:
tac celery.log | sed -n '80p'
add a comment |Â
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
3
down vote
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.
add a comment |Â
up vote
3
down vote
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.
add a comment |Â
up vote
3
down vote
up vote
3
down vote
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.
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.
edited May 8 at 8:40
answered May 8 at 7:42
Kusalananda
102k13199315
102k13199315
add a comment |Â
add a comment |Â
up vote
2
down vote
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).
add a comment |Â
up vote
2
down vote
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).
add a comment |Â
up vote
2
down vote
up vote
2
down vote
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).
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).
edited May 8 at 8:20
Stéphane Chazelas
279k53514845
279k53514845
answered May 8 at 7:35
Kyrie001
434
434
add a comment |Â
add a comment |Â
up vote
1
down vote
Yo can do this:
tac celery.log | sed -n '80p'
add a comment |Â
up vote
1
down vote
Yo can do this:
tac celery.log | sed -n '80p'
add a comment |Â
up vote
1
down vote
up vote
1
down vote
Yo can do this:
tac celery.log | sed -n '80p'
Yo can do this:
tac celery.log | sed -n '80p'
answered May 8 at 7:38
matsib.dev
14613
14613
add a comment |Â
add a comment |Â
2
What do you mean by "go to"?
â Kusalananda
May 8 at 7:26
The equivilant of
tail
command but go to the 80th last line instead of the default.â Zorgan
May 8 at 7:27
4
like
tail -n80 celery.log
?â Charles
May 8 at 7:29
@Charles yes that's perfect. thanks!
â Zorgan
May 8 at 8:26