Why only one side of NR work? [duplicate]
Clash Royale CLAN TAG#URR8PPP
up vote
0
down vote
favorite
This question already has an answer here:
How to insert bash variables in awk?
3 answers
Using bash variable with escape character in awk to extract lines from file
1 answer
I am very confused about one simple script with awk: I want to print a range of rows by passing variables, the script below works:
awk ' if (NR >10 && NR < 100 ) print $0 ' file
the script below works too:
set fac = 10
awk ' if (NR >$fac && NR < 100 ) print $0 ' file
BUT this script NOT works, WHY? I am so confused. thank you for help.
set fac = 100
awk ' if (NR >10 && NR <$fac ) print $0 ' file
awk less
marked as duplicate by Thomas Dickey, jasonwryan, ñÃÂsýù÷, muru, Kiwy Jun 14 at 10:27
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:
How to insert bash variables in awk?
3 answers
Using bash variable with escape character in awk to extract lines from file
1 answer
I am very confused about one simple script with awk: I want to print a range of rows by passing variables, the script below works:
awk ' if (NR >10 && NR < 100 ) print $0 ' file
the script below works too:
set fac = 10
awk ' if (NR >$fac && NR < 100 ) print $0 ' file
BUT this script NOT works, WHY? I am so confused. thank you for help.
set fac = 100
awk ' if (NR >10 && NR <$fac ) print $0 ' file
awk less
marked as duplicate by Thomas Dickey, jasonwryan, ñÃÂsýù÷, muru, Kiwy Jun 14 at 10:27
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.
There are many duplicates for this...
â Thomas Dickey
Jun 14 at 1:13
1
also I don't think so your second commmad does works, it will beNR >0 && NR < 100
and you will getting first 99 lines and third commandNR >10 && NR <0
and since no NR is <0 then it won't print anything at all
â Ã±ÃÂsýù÷
Jun 14 at 1:52
@ThomasDickey, thank you. With your hint, I figure out how to get it work by adding "-v" like below, but still not sure why the second script work? awk -v a="$fac1" -v b="$fac2" 'if (NR>a && NR<b) print $0'
â kelly
Jun 14 at 2:07
add a comment |Â
up vote
0
down vote
favorite
up vote
0
down vote
favorite
This question already has an answer here:
How to insert bash variables in awk?
3 answers
Using bash variable with escape character in awk to extract lines from file
1 answer
I am very confused about one simple script with awk: I want to print a range of rows by passing variables, the script below works:
awk ' if (NR >10 && NR < 100 ) print $0 ' file
the script below works too:
set fac = 10
awk ' if (NR >$fac && NR < 100 ) print $0 ' file
BUT this script NOT works, WHY? I am so confused. thank you for help.
set fac = 100
awk ' if (NR >10 && NR <$fac ) print $0 ' file
awk less
This question already has an answer here:
How to insert bash variables in awk?
3 answers
Using bash variable with escape character in awk to extract lines from file
1 answer
I am very confused about one simple script with awk: I want to print a range of rows by passing variables, the script below works:
awk ' if (NR >10 && NR < 100 ) print $0 ' file
the script below works too:
set fac = 10
awk ' if (NR >$fac && NR < 100 ) print $0 ' file
BUT this script NOT works, WHY? I am so confused. thank you for help.
set fac = 100
awk ' if (NR >10 && NR <$fac ) print $0 ' file
This question already has an answer here:
How to insert bash variables in awk?
3 answers
Using bash variable with escape character in awk to extract lines from file
1 answer
awk less
asked Jun 14 at 1:09
kelly
133
133
marked as duplicate by Thomas Dickey, jasonwryan, ñÃÂsýù÷, muru, Kiwy Jun 14 at 10:27
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 Thomas Dickey, jasonwryan, ñÃÂsýù÷, muru, Kiwy Jun 14 at 10:27
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.
There are many duplicates for this...
â Thomas Dickey
Jun 14 at 1:13
1
also I don't think so your second commmad does works, it will beNR >0 && NR < 100
and you will getting first 99 lines and third commandNR >10 && NR <0
and since no NR is <0 then it won't print anything at all
â Ã±ÃÂsýù÷
Jun 14 at 1:52
@ThomasDickey, thank you. With your hint, I figure out how to get it work by adding "-v" like below, but still not sure why the second script work? awk -v a="$fac1" -v b="$fac2" 'if (NR>a && NR<b) print $0'
â kelly
Jun 14 at 2:07
add a comment |Â
There are many duplicates for this...
â Thomas Dickey
Jun 14 at 1:13
1
also I don't think so your second commmad does works, it will beNR >0 && NR < 100
and you will getting first 99 lines and third commandNR >10 && NR <0
and since no NR is <0 then it won't print anything at all
â Ã±ÃÂsýù÷
Jun 14 at 1:52
@ThomasDickey, thank you. With your hint, I figure out how to get it work by adding "-v" like below, but still not sure why the second script work? awk -v a="$fac1" -v b="$fac2" 'if (NR>a && NR<b) print $0'
â kelly
Jun 14 at 2:07
There are many duplicates for this...
â Thomas Dickey
Jun 14 at 1:13
There are many duplicates for this...
â Thomas Dickey
Jun 14 at 1:13
1
1
also I don't think so your second commmad does works, it will be
NR >0 && NR < 100
and you will getting first 99 lines and third command NR >10 && NR <0
and since no NR is <0 then it won't print anything at allâ Ã±ÃÂsýù÷
Jun 14 at 1:52
also I don't think so your second commmad does works, it will be
NR >0 && NR < 100
and you will getting first 99 lines and third command NR >10 && NR <0
and since no NR is <0 then it won't print anything at allâ Ã±ÃÂsýù÷
Jun 14 at 1:52
@ThomasDickey, thank you. With your hint, I figure out how to get it work by adding "-v" like below, but still not sure why the second script work? awk -v a="$fac1" -v b="$fac2" 'if (NR>a && NR<b) print $0'
â kelly
Jun 14 at 2:07
@ThomasDickey, thank you. With your hint, I figure out how to get it work by adding "-v" like below, but still not sure why the second script work? awk -v a="$fac1" -v b="$fac2" 'if (NR>a && NR<b) print $0'
â kelly
Jun 14 at 2:07
add a comment |Â
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
There are many duplicates for this...
â Thomas Dickey
Jun 14 at 1:13
1
also I don't think so your second commmad does works, it will be
NR >0 && NR < 100
and you will getting first 99 lines and third commandNR >10 && NR <0
and since no NR is <0 then it won't print anything at allâ Ã±ÃÂsýù÷
Jun 14 at 1:52
@ThomasDickey, thank you. With your hint, I figure out how to get it work by adding "-v" like below, but still not sure why the second script work? awk -v a="$fac1" -v b="$fac2" 'if (NR>a && NR<b) print $0'
â kelly
Jun 14 at 2:07