print line only if number in third field is greater than X [duplicate]
Clash Royale CLAN TAG#URR8PPP
up vote
-1
down vote
favorite
This question already has an answer here:
remove lines where a field's value is less than or equal to 3 - sed or awk?
1 answer
get all rows having a column value greater than a threshold
2 answers
The following lsblk
command print the disk usage in bytes
lsblk -bio KNAME,TYPE,SIZE,MODEL| grep disk
sda disk 298999349248 AVAGO
sdb disk 1998998994944 AVAGO
sdc disk 1998998994944 AVAGO
sdd disk 1998998994944 AVAGO
sde disk 98998994944 AVAGO
how to print the disks when disk is greater than 300000000000 , by adding after the pipe awk
or perl
one-liner or else
expected output:
lsblk -bio KNAME,TYPE,SIZE,MODEL| grep disk | ......
sdb disk 1998998994944 AVAGO
sdc disk 1998998994944 AVAGO
sdd disk 1998998994944 AVAGO
linux text-processing awk sed perl
marked as duplicate by Anthony Geoghegan, don_crissti, Archemar, Jeff Schaller, Anthon Oct 2 '17 at 12:16
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
-1
down vote
favorite
This question already has an answer here:
remove lines where a field's value is less than or equal to 3 - sed or awk?
1 answer
get all rows having a column value greater than a threshold
2 answers
The following lsblk
command print the disk usage in bytes
lsblk -bio KNAME,TYPE,SIZE,MODEL| grep disk
sda disk 298999349248 AVAGO
sdb disk 1998998994944 AVAGO
sdc disk 1998998994944 AVAGO
sdd disk 1998998994944 AVAGO
sde disk 98998994944 AVAGO
how to print the disks when disk is greater than 300000000000 , by adding after the pipe awk
or perl
one-liner or else
expected output:
lsblk -bio KNAME,TYPE,SIZE,MODEL| grep disk | ......
sdb disk 1998998994944 AVAGO
sdc disk 1998998994944 AVAGO
sdd disk 1998998994944 AVAGO
linux text-processing awk sed perl
marked as duplicate by Anthony Geoghegan, don_crissti, Archemar, Jeff Schaller, Anthon Oct 2 '17 at 12:16
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.
awk '$3 >= 1998998994944' infile
Sice your output doesn't have a disk larger than300000000000
you won't be able to print anything. The syntax will work in general.$3 > some_value
then print.
â Valentin B
Oct 2 '17 at 8:19
I not want to work with files
â yael
Oct 2 '17 at 8:24
add a comment |Â
up vote
-1
down vote
favorite
up vote
-1
down vote
favorite
This question already has an answer here:
remove lines where a field's value is less than or equal to 3 - sed or awk?
1 answer
get all rows having a column value greater than a threshold
2 answers
The following lsblk
command print the disk usage in bytes
lsblk -bio KNAME,TYPE,SIZE,MODEL| grep disk
sda disk 298999349248 AVAGO
sdb disk 1998998994944 AVAGO
sdc disk 1998998994944 AVAGO
sdd disk 1998998994944 AVAGO
sde disk 98998994944 AVAGO
how to print the disks when disk is greater than 300000000000 , by adding after the pipe awk
or perl
one-liner or else
expected output:
lsblk -bio KNAME,TYPE,SIZE,MODEL| grep disk | ......
sdb disk 1998998994944 AVAGO
sdc disk 1998998994944 AVAGO
sdd disk 1998998994944 AVAGO
linux text-processing awk sed perl
This question already has an answer here:
remove lines where a field's value is less than or equal to 3 - sed or awk?
1 answer
get all rows having a column value greater than a threshold
2 answers
The following lsblk
command print the disk usage in bytes
lsblk -bio KNAME,TYPE,SIZE,MODEL| grep disk
sda disk 298999349248 AVAGO
sdb disk 1998998994944 AVAGO
sdc disk 1998998994944 AVAGO
sdd disk 1998998994944 AVAGO
sde disk 98998994944 AVAGO
how to print the disks when disk is greater than 300000000000 , by adding after the pipe awk
or perl
one-liner or else
expected output:
lsblk -bio KNAME,TYPE,SIZE,MODEL| grep disk | ......
sdb disk 1998998994944 AVAGO
sdc disk 1998998994944 AVAGO
sdd disk 1998998994944 AVAGO
This question already has an answer here:
remove lines where a field's value is less than or equal to 3 - sed or awk?
1 answer
get all rows having a column value greater than a threshold
2 answers
linux text-processing awk sed perl
linux text-processing awk sed perl
edited Oct 2 '17 at 9:18
Jeff Schaller
32.3k849109
32.3k849109
asked Oct 2 '17 at 8:14
yael
2,0361145
2,0361145
marked as duplicate by Anthony Geoghegan, don_crissti, Archemar, Jeff Schaller, Anthon Oct 2 '17 at 12:16
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 Anthony Geoghegan, don_crissti, Archemar, Jeff Schaller, Anthon Oct 2 '17 at 12:16
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.
awk '$3 >= 1998998994944' infile
Sice your output doesn't have a disk larger than300000000000
you won't be able to print anything. The syntax will work in general.$3 > some_value
then print.
â Valentin B
Oct 2 '17 at 8:19
I not want to work with files
â yael
Oct 2 '17 at 8:24
add a comment |Â
awk '$3 >= 1998998994944' infile
Sice your output doesn't have a disk larger than300000000000
you won't be able to print anything. The syntax will work in general.$3 > some_value
then print.
â Valentin B
Oct 2 '17 at 8:19
I not want to work with files
â yael
Oct 2 '17 at 8:24
awk '$3 >= 1998998994944' infile
Sice your output doesn't have a disk larger than 300000000000
you won't be able to print anything. The syntax will work in general. $3 > some_value
then print.â Valentin B
Oct 2 '17 at 8:19
awk '$3 >= 1998998994944' infile
Sice your output doesn't have a disk larger than 300000000000
you won't be able to print anything. The syntax will work in general. $3 > some_value
then print.â Valentin B
Oct 2 '17 at 8:19
I not want to work with files
â yael
Oct 2 '17 at 8:24
I not want to work with files
â yael
Oct 2 '17 at 8:24
add a comment |Â
3 Answers
3
active
oldest
votes
up vote
3
down vote
You can do it with awk
itself for pattern matching instead of using grep
.
lsblk -bio KNAME,TYPE,SIZE,MODEL| awk '/disk/ && $3> 300000000000 || NR==1'
Or use scientific value 3e11
.
add a comment |Â
up vote
1
down vote
Perl solution:
lsblk -bio KNAME,TYPE,SIZE,MODEL | perl -ane 'print if $F[2] > 3e11'
You can use 300_000_000_000 as the value also.
-n
reads the input line by line without printing-a
splits the input on whitespace into the @F array
add a comment |Â
up vote
1
down vote
Short Awk approach:
lsblk -nbio KNAME,TYPE,SIZE,MODEL | awk '$3>3e11'
-n
(--noheadings
) - don't print headings$3
- the 3rd field (SIZE
column)3e11
- E-notation. the letterE
(ore
) is often used to represent "times ten raised to the power of" (which would be written as"ÃÂ 10n
") and is followed by the value of the exponent; in other words, for any two real numbersm
andn
, the usage of "mEn
" would indicate a value ofm ÃÂ 10n
.3e11
is equivalent to300000000000
.
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
You can do it with awk
itself for pattern matching instead of using grep
.
lsblk -bio KNAME,TYPE,SIZE,MODEL| awk '/disk/ && $3> 300000000000 || NR==1'
Or use scientific value 3e11
.
add a comment |Â
up vote
3
down vote
You can do it with awk
itself for pattern matching instead of using grep
.
lsblk -bio KNAME,TYPE,SIZE,MODEL| awk '/disk/ && $3> 300000000000 || NR==1'
Or use scientific value 3e11
.
add a comment |Â
up vote
3
down vote
up vote
3
down vote
You can do it with awk
itself for pattern matching instead of using grep
.
lsblk -bio KNAME,TYPE,SIZE,MODEL| awk '/disk/ && $3> 300000000000 || NR==1'
Or use scientific value 3e11
.
You can do it with awk
itself for pattern matching instead of using grep
.
lsblk -bio KNAME,TYPE,SIZE,MODEL| awk '/disk/ && $3> 300000000000 || NR==1'
Or use scientific value 3e11
.
answered Oct 2 '17 at 8:27
ñÃÂsýù÷
15.7k92563
15.7k92563
add a comment |Â
add a comment |Â
up vote
1
down vote
Perl solution:
lsblk -bio KNAME,TYPE,SIZE,MODEL | perl -ane 'print if $F[2] > 3e11'
You can use 300_000_000_000 as the value also.
-n
reads the input line by line without printing-a
splits the input on whitespace into the @F array
add a comment |Â
up vote
1
down vote
Perl solution:
lsblk -bio KNAME,TYPE,SIZE,MODEL | perl -ane 'print if $F[2] > 3e11'
You can use 300_000_000_000 as the value also.
-n
reads the input line by line without printing-a
splits the input on whitespace into the @F array
add a comment |Â
up vote
1
down vote
up vote
1
down vote
Perl solution:
lsblk -bio KNAME,TYPE,SIZE,MODEL | perl -ane 'print if $F[2] > 3e11'
You can use 300_000_000_000 as the value also.
-n
reads the input line by line without printing-a
splits the input on whitespace into the @F array
Perl solution:
lsblk -bio KNAME,TYPE,SIZE,MODEL | perl -ane 'print if $F[2] > 3e11'
You can use 300_000_000_000 as the value also.
-n
reads the input line by line without printing-a
splits the input on whitespace into the @F array
answered Oct 2 '17 at 8:25
choroba
24.5k34168
24.5k34168
add a comment |Â
add a comment |Â
up vote
1
down vote
Short Awk approach:
lsblk -nbio KNAME,TYPE,SIZE,MODEL | awk '$3>3e11'
-n
(--noheadings
) - don't print headings$3
- the 3rd field (SIZE
column)3e11
- E-notation. the letterE
(ore
) is often used to represent "times ten raised to the power of" (which would be written as"ÃÂ 10n
") and is followed by the value of the exponent; in other words, for any two real numbersm
andn
, the usage of "mEn
" would indicate a value ofm ÃÂ 10n
.3e11
is equivalent to300000000000
.
add a comment |Â
up vote
1
down vote
Short Awk approach:
lsblk -nbio KNAME,TYPE,SIZE,MODEL | awk '$3>3e11'
-n
(--noheadings
) - don't print headings$3
- the 3rd field (SIZE
column)3e11
- E-notation. the letterE
(ore
) is often used to represent "times ten raised to the power of" (which would be written as"ÃÂ 10n
") and is followed by the value of the exponent; in other words, for any two real numbersm
andn
, the usage of "mEn
" would indicate a value ofm ÃÂ 10n
.3e11
is equivalent to300000000000
.
add a comment |Â
up vote
1
down vote
up vote
1
down vote
Short Awk approach:
lsblk -nbio KNAME,TYPE,SIZE,MODEL | awk '$3>3e11'
-n
(--noheadings
) - don't print headings$3
- the 3rd field (SIZE
column)3e11
- E-notation. the letterE
(ore
) is often used to represent "times ten raised to the power of" (which would be written as"ÃÂ 10n
") and is followed by the value of the exponent; in other words, for any two real numbersm
andn
, the usage of "mEn
" would indicate a value ofm ÃÂ 10n
.3e11
is equivalent to300000000000
.
Short Awk approach:
lsblk -nbio KNAME,TYPE,SIZE,MODEL | awk '$3>3e11'
-n
(--noheadings
) - don't print headings$3
- the 3rd field (SIZE
column)3e11
- E-notation. the letterE
(ore
) is often used to represent "times ten raised to the power of" (which would be written as"ÃÂ 10n
") and is followed by the value of the exponent; in other words, for any two real numbersm
andn
, the usage of "mEn
" would indicate a value ofm ÃÂ 10n
.3e11
is equivalent to300000000000
.
edited Oct 2 '17 at 8:45
answered Oct 2 '17 at 8:28
RomanPerekhrest
22.5k12145
22.5k12145
add a comment |Â
add a comment |Â
awk '$3 >= 1998998994944' infile
Sice your output doesn't have a disk larger than300000000000
you won't be able to print anything. The syntax will work in general.$3 > some_value
then print.â Valentin B
Oct 2 '17 at 8:19
I not want to work with files
â yael
Oct 2 '17 at 8:24