Cut off the first two lines
Clash Royale CLAN TAG#URR8PPP
up vote
0
down vote
favorite
I'd like to retrive a list excluding the first 2 lines
$ pip list
Package Version
---------------------------------- ---------
alabaster 0.7.10
anaconda-client 1.6.9
anaconda-navigator 1.7.0
anaconda-project 0.8.2
appnope 0.1.0
appscript 1.0.1
asn1crypto 0.24.0
astroid 1.6.1
astropy 2.0.3
attrs 17.4.0
How to cut off the first two line like:
pip list | cut line=2
text-processing cut text-formatting
add a comment |Â
up vote
0
down vote
favorite
I'd like to retrive a list excluding the first 2 lines
$ pip list
Package Version
---------------------------------- ---------
alabaster 0.7.10
anaconda-client 1.6.9
anaconda-navigator 1.7.0
anaconda-project 0.8.2
appnope 0.1.0
appscript 1.0.1
asn1crypto 0.24.0
astroid 1.6.1
astropy 2.0.3
attrs 17.4.0
How to cut off the first two line like:
pip list | cut line=2
text-processing cut text-formatting
1
awk 'NR>2' file
...
â jasonwryan
May 3 at 7:08
add a comment |Â
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I'd like to retrive a list excluding the first 2 lines
$ pip list
Package Version
---------------------------------- ---------
alabaster 0.7.10
anaconda-client 1.6.9
anaconda-navigator 1.7.0
anaconda-project 0.8.2
appnope 0.1.0
appscript 1.0.1
asn1crypto 0.24.0
astroid 1.6.1
astropy 2.0.3
attrs 17.4.0
How to cut off the first two line like:
pip list | cut line=2
text-processing cut text-formatting
I'd like to retrive a list excluding the first 2 lines
$ pip list
Package Version
---------------------------------- ---------
alabaster 0.7.10
anaconda-client 1.6.9
anaconda-navigator 1.7.0
anaconda-project 0.8.2
appnope 0.1.0
appscript 1.0.1
asn1crypto 0.24.0
astroid 1.6.1
astropy 2.0.3
attrs 17.4.0
How to cut off the first two line like:
pip list | cut line=2
text-processing cut text-formatting
edited May 3 at 7:14
Inian
2,855722
2,855722
asked May 3 at 7:05
JawSaw
29410
29410
1
awk 'NR>2' file
...
â jasonwryan
May 3 at 7:08
add a comment |Â
1
awk 'NR>2' file
...
â jasonwryan
May 3 at 7:08
1
1
awk 'NR>2' file
...â jasonwryan
May 3 at 7:08
awk 'NR>2' file
...â jasonwryan
May 3 at 7:08
add a comment |Â
2 Answers
2
active
oldest
votes
up vote
2
down vote
accepted
Simply with the sed
command:
pip list | sed '1,2d'
Explanation: The sed
command deletes (d
) lines in the range 1 to 2 (and outputs everything else).
Or awk
:
pip list | awk 'NR > 2'
Explanation: The awk
program outputs everything on line 3 onwards.
awk
would be particularly useful if you are planning to do further parsing of that output, such as extracting only the package names:
pip list | awk 'NR > 2 print $1 '
The cut
command, that you mention in the question (disregarding that the semantics used is wrong), does not cut lines. Well, it does, but it cuts fields out of lines.
Actually, with GNUcut
, one can doseq 20 | cut -d$'n' -f3-
â Stéphane Chazelas
May 3 at 7:47
@StéphaneChazelas That's treating the whole file as an
-delimited set of fields on a single line, so in a sense it's still cutting fields out of a line, but yes.
â Kusalananda
May 3 at 7:49
An advantage of usingtail
, beside the fact that it's going to be more efficient as it's the simple tool designed to that task is that with most implementations including non-GNU ones, it's going to work even on non-text input (like with very long lines, with NULs or sequences of bytes that don't form valid characters...), while severalsed
orawk
implementations would choke on those.
â Stéphane Chazelas
May 3 at 7:50
@StéphaneChazelas The only reason I did not mention tail was that it is already mentioned in another answer.
â Kusalananda
May 3 at 8:06
1
Yes, I don't doubt that. Those comments were just additional notes, not a critique to your answer.
â Stéphane Chazelas
May 3 at 8:15
add a comment |Â
up vote
6
down vote
Simply with tail
command:
pip list | tail -n+3 -
- from
tail
signaturetail [OPTION]... [FILE]...
- whenFILE
is-
, read standard input -n, --lines=[+]NUM
- output the lastNUM
lines, instead of the last 10; or use-n +NUM
to output starting with lineNUM
add a comment |Â
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
2
down vote
accepted
Simply with the sed
command:
pip list | sed '1,2d'
Explanation: The sed
command deletes (d
) lines in the range 1 to 2 (and outputs everything else).
Or awk
:
pip list | awk 'NR > 2'
Explanation: The awk
program outputs everything on line 3 onwards.
awk
would be particularly useful if you are planning to do further parsing of that output, such as extracting only the package names:
pip list | awk 'NR > 2 print $1 '
The cut
command, that you mention in the question (disregarding that the semantics used is wrong), does not cut lines. Well, it does, but it cuts fields out of lines.
Actually, with GNUcut
, one can doseq 20 | cut -d$'n' -f3-
â Stéphane Chazelas
May 3 at 7:47
@StéphaneChazelas That's treating the whole file as an
-delimited set of fields on a single line, so in a sense it's still cutting fields out of a line, but yes.
â Kusalananda
May 3 at 7:49
An advantage of usingtail
, beside the fact that it's going to be more efficient as it's the simple tool designed to that task is that with most implementations including non-GNU ones, it's going to work even on non-text input (like with very long lines, with NULs or sequences of bytes that don't form valid characters...), while severalsed
orawk
implementations would choke on those.
â Stéphane Chazelas
May 3 at 7:50
@StéphaneChazelas The only reason I did not mention tail was that it is already mentioned in another answer.
â Kusalananda
May 3 at 8:06
1
Yes, I don't doubt that. Those comments were just additional notes, not a critique to your answer.
â Stéphane Chazelas
May 3 at 8:15
add a comment |Â
up vote
2
down vote
accepted
Simply with the sed
command:
pip list | sed '1,2d'
Explanation: The sed
command deletes (d
) lines in the range 1 to 2 (and outputs everything else).
Or awk
:
pip list | awk 'NR > 2'
Explanation: The awk
program outputs everything on line 3 onwards.
awk
would be particularly useful if you are planning to do further parsing of that output, such as extracting only the package names:
pip list | awk 'NR > 2 print $1 '
The cut
command, that you mention in the question (disregarding that the semantics used is wrong), does not cut lines. Well, it does, but it cuts fields out of lines.
Actually, with GNUcut
, one can doseq 20 | cut -d$'n' -f3-
â Stéphane Chazelas
May 3 at 7:47
@StéphaneChazelas That's treating the whole file as an
-delimited set of fields on a single line, so in a sense it's still cutting fields out of a line, but yes.
â Kusalananda
May 3 at 7:49
An advantage of usingtail
, beside the fact that it's going to be more efficient as it's the simple tool designed to that task is that with most implementations including non-GNU ones, it's going to work even on non-text input (like with very long lines, with NULs or sequences of bytes that don't form valid characters...), while severalsed
orawk
implementations would choke on those.
â Stéphane Chazelas
May 3 at 7:50
@StéphaneChazelas The only reason I did not mention tail was that it is already mentioned in another answer.
â Kusalananda
May 3 at 8:06
1
Yes, I don't doubt that. Those comments were just additional notes, not a critique to your answer.
â Stéphane Chazelas
May 3 at 8:15
add a comment |Â
up vote
2
down vote
accepted
up vote
2
down vote
accepted
Simply with the sed
command:
pip list | sed '1,2d'
Explanation: The sed
command deletes (d
) lines in the range 1 to 2 (and outputs everything else).
Or awk
:
pip list | awk 'NR > 2'
Explanation: The awk
program outputs everything on line 3 onwards.
awk
would be particularly useful if you are planning to do further parsing of that output, such as extracting only the package names:
pip list | awk 'NR > 2 print $1 '
The cut
command, that you mention in the question (disregarding that the semantics used is wrong), does not cut lines. Well, it does, but it cuts fields out of lines.
Simply with the sed
command:
pip list | sed '1,2d'
Explanation: The sed
command deletes (d
) lines in the range 1 to 2 (and outputs everything else).
Or awk
:
pip list | awk 'NR > 2'
Explanation: The awk
program outputs everything on line 3 onwards.
awk
would be particularly useful if you are planning to do further parsing of that output, such as extracting only the package names:
pip list | awk 'NR > 2 print $1 '
The cut
command, that you mention in the question (disregarding that the semantics used is wrong), does not cut lines. Well, it does, but it cuts fields out of lines.
edited May 3 at 8:26
answered May 3 at 7:16
Kusalananda
102k13199316
102k13199316
Actually, with GNUcut
, one can doseq 20 | cut -d$'n' -f3-
â Stéphane Chazelas
May 3 at 7:47
@StéphaneChazelas That's treating the whole file as an
-delimited set of fields on a single line, so in a sense it's still cutting fields out of a line, but yes.
â Kusalananda
May 3 at 7:49
An advantage of usingtail
, beside the fact that it's going to be more efficient as it's the simple tool designed to that task is that with most implementations including non-GNU ones, it's going to work even on non-text input (like with very long lines, with NULs or sequences of bytes that don't form valid characters...), while severalsed
orawk
implementations would choke on those.
â Stéphane Chazelas
May 3 at 7:50
@StéphaneChazelas The only reason I did not mention tail was that it is already mentioned in another answer.
â Kusalananda
May 3 at 8:06
1
Yes, I don't doubt that. Those comments were just additional notes, not a critique to your answer.
â Stéphane Chazelas
May 3 at 8:15
add a comment |Â
Actually, with GNUcut
, one can doseq 20 | cut -d$'n' -f3-
â Stéphane Chazelas
May 3 at 7:47
@StéphaneChazelas That's treating the whole file as an
-delimited set of fields on a single line, so in a sense it's still cutting fields out of a line, but yes.
â Kusalananda
May 3 at 7:49
An advantage of usingtail
, beside the fact that it's going to be more efficient as it's the simple tool designed to that task is that with most implementations including non-GNU ones, it's going to work even on non-text input (like with very long lines, with NULs or sequences of bytes that don't form valid characters...), while severalsed
orawk
implementations would choke on those.
â Stéphane Chazelas
May 3 at 7:50
@StéphaneChazelas The only reason I did not mention tail was that it is already mentioned in another answer.
â Kusalananda
May 3 at 8:06
1
Yes, I don't doubt that. Those comments were just additional notes, not a critique to your answer.
â Stéphane Chazelas
May 3 at 8:15
Actually, with GNU
cut
, one can do seq 20 | cut -d$'n' -f3-
â Stéphane Chazelas
May 3 at 7:47
Actually, with GNU
cut
, one can do seq 20 | cut -d$'n' -f3-
â Stéphane Chazelas
May 3 at 7:47
@StéphaneChazelas That's treating the whole file as a
n
-delimited set of fields on a single line, so in a sense it's still cutting fields out of a line, but yes.â Kusalananda
May 3 at 7:49
@StéphaneChazelas That's treating the whole file as a
n
-delimited set of fields on a single line, so in a sense it's still cutting fields out of a line, but yes.â Kusalananda
May 3 at 7:49
An advantage of using
tail
, beside the fact that it's going to be more efficient as it's the simple tool designed to that task is that with most implementations including non-GNU ones, it's going to work even on non-text input (like with very long lines, with NULs or sequences of bytes that don't form valid characters...), while several sed
or awk
implementations would choke on those.â Stéphane Chazelas
May 3 at 7:50
An advantage of using
tail
, beside the fact that it's going to be more efficient as it's the simple tool designed to that task is that with most implementations including non-GNU ones, it's going to work even on non-text input (like with very long lines, with NULs or sequences of bytes that don't form valid characters...), while several sed
or awk
implementations would choke on those.â Stéphane Chazelas
May 3 at 7:50
@StéphaneChazelas The only reason I did not mention tail was that it is already mentioned in another answer.
â Kusalananda
May 3 at 8:06
@StéphaneChazelas The only reason I did not mention tail was that it is already mentioned in another answer.
â Kusalananda
May 3 at 8:06
1
1
Yes, I don't doubt that. Those comments were just additional notes, not a critique to your answer.
â Stéphane Chazelas
May 3 at 8:15
Yes, I don't doubt that. Those comments were just additional notes, not a critique to your answer.
â Stéphane Chazelas
May 3 at 8:15
add a comment |Â
up vote
6
down vote
Simply with tail
command:
pip list | tail -n+3 -
- from
tail
signaturetail [OPTION]... [FILE]...
- whenFILE
is-
, read standard input -n, --lines=[+]NUM
- output the lastNUM
lines, instead of the last 10; or use-n +NUM
to output starting with lineNUM
add a comment |Â
up vote
6
down vote
Simply with tail
command:
pip list | tail -n+3 -
- from
tail
signaturetail [OPTION]... [FILE]...
- whenFILE
is-
, read standard input -n, --lines=[+]NUM
- output the lastNUM
lines, instead of the last 10; or use-n +NUM
to output starting with lineNUM
add a comment |Â
up vote
6
down vote
up vote
6
down vote
Simply with tail
command:
pip list | tail -n+3 -
- from
tail
signaturetail [OPTION]... [FILE]...
- whenFILE
is-
, read standard input -n, --lines=[+]NUM
- output the lastNUM
lines, instead of the last 10; or use-n +NUM
to output starting with lineNUM
Simply with tail
command:
pip list | tail -n+3 -
- from
tail
signaturetail [OPTION]... [FILE]...
- whenFILE
is-
, read standard input -n, --lines=[+]NUM
- output the lastNUM
lines, instead of the last 10; or use-n +NUM
to output starting with lineNUM
edited May 3 at 7:20
answered May 3 at 7:11
RomanPerekhrest
22.4k12144
22.4k12144
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f441473%2fcut-off-the-first-two-lines%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
1
awk 'NR>2' file
...â jasonwryan
May 3 at 7:08