Find the answer to your Linux question:
Results 1 to 3 of 3
I have a input file like this, only 7 rows are shown here for simplicity input.txt 3.4 2 1 5 6 8 2.3 5 6 2.4 2 5 5 6 ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    yat
    yat is offline
    Just Joined!
    Join Date
    May 2011
    Posts
    8

    print rows that have match data in spesific column


    I have a input file like this, only 7 rows are shown here for simplicity

    input.txt

    3.4 2 1 5 6 8
    2.3 5 6
    2.4 2 5 5 6 8
    6.5 9 8
    7.2 6 7 8 9 6
    5.4 3 2
    9.0 6 4

    I want an output that will print the entire row that have column 4,5 and 6 value of 5 6 8 like this:

    output.txt

    3.4 2 1 5 6 8
    2.4 2 5 5 6 8

    helps are much appreciated, tq

  2. #2
    tpl
    tpl is offline
    Linux User
    Join Date
    Jan 2007
    Location
    cleveland
    Posts
    477
    try something like this:

    awk '(($4==5)&&($5==6))&&($6== { print }' <input.txt

    awk will print every line satisfying the conjunctive condition
    the sun is new every day (heraclitus)

  3. #3
    Just Joined!
    Join Date
    Apr 2013
    Location
    Gurgaon, India
    Posts
    6
    He is right

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •