print line only if number in third field is greater than X [duplicate]

The name of the pictureThe name of the pictureThe name of the pictureClash 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









share|improve this 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 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














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









share|improve this 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 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












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









share|improve this question
















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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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 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
















  • 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















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










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.






share|improve this answer



























    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





    share|improve this answer



























      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 letter E (or e) 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 numbers m and n, the usage of "mEn" would indicate a value of m × 10n. 3e11 is equivalent to 300000000000.






      share|improve this answer





























        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.






        share|improve this answer
























          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.






          share|improve this answer






















            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.






            share|improve this answer












            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.







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Oct 2 '17 at 8:27









            αғsнιη

            15.7k92563




            15.7k92563






















                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





                share|improve this answer
























                  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





                  share|improve this answer






















                    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





                    share|improve this answer












                    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






                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered Oct 2 '17 at 8:25









                    choroba

                    24.5k34168




                    24.5k34168




















                        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 letter E (or e) 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 numbers m and n, the usage of "mEn" would indicate a value of m × 10n. 3e11 is equivalent to 300000000000.






                        share|improve this answer


























                          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 letter E (or e) 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 numbers m and n, the usage of "mEn" would indicate a value of m × 10n. 3e11 is equivalent to 300000000000.






                          share|improve this answer
























                            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 letter E (or e) 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 numbers m and n, the usage of "mEn" would indicate a value of m × 10n. 3e11 is equivalent to 300000000000.






                            share|improve this answer














                            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 letter E (or e) 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 numbers m and n, the usage of "mEn" would indicate a value of m × 10n. 3e11 is equivalent to 300000000000.







                            share|improve this answer














                            share|improve this answer



                            share|improve this answer








                            edited Oct 2 '17 at 8:45

























                            answered Oct 2 '17 at 8:28









                            RomanPerekhrest

                            22.5k12145




                            22.5k12145












                                Popular posts from this blog

                                How to check contact read email or not when send email to Individual?

                                Bahrain

                                Postfix configuration issue with fips on centos 7; mailgun relay