Awk to print lines in file with multiple delimiters












1














I have a file that looks like:



chr1    1197592 .   C   A   .   .   DP=67;ECNT=1;NLOD=8.12  GT:AD:AF:F1R2   0/1:37,2:0.063:13,0
chr1 1355707 . G T . . DP=69;ECNT=1;NLOD=4.51 GT:AD:AF:F1R2 0/1:50,3:0.059:20,3
chr1 1641723 . TC T . . DP=59;ECNT=1;NLOD=2.40 GT:AD:AF:F1R2 0/1:30,2:0.089:12,4
chr1 2550056 . TC CT . . DP=99;ECNT=1;NLOD=9.03 GT:AD:AF:F1R2 0/1:63,2:0.053:33,2


I would like to print the lines for which the 3rd value in the 10th column is greater than 0.06.



cat file.txt | cut -f 10 | cut -f 3 | awk -F':' '$3>0.06'


Will only give me:



0/1:37,2:0.063:13,0
0/1:30,2:0.089:12,4


And I would like the entire line. Can that be done with awk?










share|improve this question









New contributor




lindak is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




















  • Since you're working with VCF files, an extremely complex format whose variety is not represented in this limited example, you might want to consider our sister site Bioinformatics for future questions, since the users there will be much more aware of the details of this format and how to deal with it.
    – terdon
    5 hours ago










  • Thanks @terdon, i will consider it next time!
    – lindak
    5 hours ago
















1














I have a file that looks like:



chr1    1197592 .   C   A   .   .   DP=67;ECNT=1;NLOD=8.12  GT:AD:AF:F1R2   0/1:37,2:0.063:13,0
chr1 1355707 . G T . . DP=69;ECNT=1;NLOD=4.51 GT:AD:AF:F1R2 0/1:50,3:0.059:20,3
chr1 1641723 . TC T . . DP=59;ECNT=1;NLOD=2.40 GT:AD:AF:F1R2 0/1:30,2:0.089:12,4
chr1 2550056 . TC CT . . DP=99;ECNT=1;NLOD=9.03 GT:AD:AF:F1R2 0/1:63,2:0.053:33,2


I would like to print the lines for which the 3rd value in the 10th column is greater than 0.06.



cat file.txt | cut -f 10 | cut -f 3 | awk -F':' '$3>0.06'


Will only give me:



0/1:37,2:0.063:13,0
0/1:30,2:0.089:12,4


And I would like the entire line. Can that be done with awk?










share|improve this question









New contributor




lindak is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




















  • Since you're working with VCF files, an extremely complex format whose variety is not represented in this limited example, you might want to consider our sister site Bioinformatics for future questions, since the users there will be much more aware of the details of this format and how to deal with it.
    – terdon
    5 hours ago










  • Thanks @terdon, i will consider it next time!
    – lindak
    5 hours ago














1












1








1


1





I have a file that looks like:



chr1    1197592 .   C   A   .   .   DP=67;ECNT=1;NLOD=8.12  GT:AD:AF:F1R2   0/1:37,2:0.063:13,0
chr1 1355707 . G T . . DP=69;ECNT=1;NLOD=4.51 GT:AD:AF:F1R2 0/1:50,3:0.059:20,3
chr1 1641723 . TC T . . DP=59;ECNT=1;NLOD=2.40 GT:AD:AF:F1R2 0/1:30,2:0.089:12,4
chr1 2550056 . TC CT . . DP=99;ECNT=1;NLOD=9.03 GT:AD:AF:F1R2 0/1:63,2:0.053:33,2


I would like to print the lines for which the 3rd value in the 10th column is greater than 0.06.



cat file.txt | cut -f 10 | cut -f 3 | awk -F':' '$3>0.06'


Will only give me:



0/1:37,2:0.063:13,0
0/1:30,2:0.089:12,4


And I would like the entire line. Can that be done with awk?










share|improve this question









New contributor




lindak is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











I have a file that looks like:



chr1    1197592 .   C   A   .   .   DP=67;ECNT=1;NLOD=8.12  GT:AD:AF:F1R2   0/1:37,2:0.063:13,0
chr1 1355707 . G T . . DP=69;ECNT=1;NLOD=4.51 GT:AD:AF:F1R2 0/1:50,3:0.059:20,3
chr1 1641723 . TC T . . DP=59;ECNT=1;NLOD=2.40 GT:AD:AF:F1R2 0/1:30,2:0.089:12,4
chr1 2550056 . TC CT . . DP=99;ECNT=1;NLOD=9.03 GT:AD:AF:F1R2 0/1:63,2:0.053:33,2


I would like to print the lines for which the 3rd value in the 10th column is greater than 0.06.



cat file.txt | cut -f 10 | cut -f 3 | awk -F':' '$3>0.06'


Will only give me:



0/1:37,2:0.063:13,0
0/1:30,2:0.089:12,4


And I would like the entire line. Can that be done with awk?







text-processing awk






share|improve this question









New contributor




lindak is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question









New contributor




lindak is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question








edited 5 hours ago









terdon

129k31252428




129k31252428






New contributor




lindak is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked 6 hours ago









lindaklindak

112




112




New contributor




lindak is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





lindak is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






lindak is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












  • Since you're working with VCF files, an extremely complex format whose variety is not represented in this limited example, you might want to consider our sister site Bioinformatics for future questions, since the users there will be much more aware of the details of this format and how to deal with it.
    – terdon
    5 hours ago










  • Thanks @terdon, i will consider it next time!
    – lindak
    5 hours ago


















  • Since you're working with VCF files, an extremely complex format whose variety is not represented in this limited example, you might want to consider our sister site Bioinformatics for future questions, since the users there will be much more aware of the details of this format and how to deal with it.
    – terdon
    5 hours ago










  • Thanks @terdon, i will consider it next time!
    – lindak
    5 hours ago
















Since you're working with VCF files, an extremely complex format whose variety is not represented in this limited example, you might want to consider our sister site Bioinformatics for future questions, since the users there will be much more aware of the details of this format and how to deal with it.
– terdon
5 hours ago




Since you're working with VCF files, an extremely complex format whose variety is not represented in this limited example, you might want to consider our sister site Bioinformatics for future questions, since the users there will be much more aware of the details of this format and how to deal with it.
– terdon
5 hours ago












Thanks @terdon, i will consider it next time!
– lindak
5 hours ago




Thanks @terdon, i will consider it next time!
– lindak
5 hours ago










4 Answers
4






active

oldest

votes


















3














As soon as you start discarding data in a pipeline (which is what cut does), you can't get it back in a later stage of the same pipeline.



Instead,



$ awk 'split($10,a,":") && a[3] > 0.06' file
chr1 1197592 . C A . . DP=67;ECNT=1;NLOD=8.12 GT:AD:AF:F1R2 0/1:37,2:0.063:13,0
chr1 1641723 . TC T . . DP=59;ECNT=1;NLOD=2.40 GT:AD:AF:F1R2 0/1:30,2:0.089:12,4


This takes the 10th whitespace-delimited field and splits it on colons into the array a. It prints the original line if the split() generated any elements in a and if the third element of a is greater than 0.06.



If the fields in the file are tab-delimited and if any field contains spaces, then use -F 't' with awk to make sure that it finds the right fields correctly (the given example data does not have any such issues as far as I can see).





Addressing the follow-up question in comments:



awk 'split($10,a,":") && a[3] > 0.06 && split($11,b,":") && b[3] > 0.01' file





share|improve this answer























  • Will it work also if i have a column 11 with similar info as in 10 to filter on them both simultaneously? E.g. to print only lines where value 3 in column 10>0.06 and value 3 in column 11>0.01. Something like: awk '(split($10,a,":") && a[3] > 0.06) && (split($11,b,":") && b[3] > 0.01)'
    – lindak
    2 hours ago












  • @lindak Yes, but the parentheses are optional there (unless you later want to change to (... && ...) || (... && ...)). See updated answer.
    – Kusalananda
    2 hours ago












  • Great, thank you!
    – lindak
    2 hours ago



















3














awk -F':' '$(NF-1) > 0.06 {print $0}' file


Just use ':' as separator and evaluate the penultimate column






share|improve this answer





















  • Thank you, it works for my example file, but my actual file has more columns which i never commented in the post, so my bad...
    – lindak
    5 hours ago



















0














Having read the comments it's clear that your sample data doesn't match your actual data (and it's using spaces instead of TABs to begin with, which means that even the command output of your own device won't work), but having clobbered together a different input file like so:



cat file.txt
chr1 1197592 . C A . . DP=67;ECNT=1;NLOD=8.12 GT:AD:AF:F1R2 0/1:37,2:0.063:13,0 0/1:37,2:0.0005:13,0
chr1 1355707 . G T . . DP=69;ECNT=1;NLOD=4.51 GT:AD:AF:F1R2 0/1:50,3:0.059:20,3 0/1:50,3:0.0005:20,3
chr1 1641723 . TC T . . DP=59;ECNT=1;NLOD=2.40 GT:AD:AF:F1R2 0/1:30,2:0.089:12,4 0/1:30,2:0.0015:12,4
chr1 2550056 . TC CT . . DP=99;ECNT=1;NLOD=9.03 GT:AD:AF:F1R2 0/1:63,2:0.053:33,2 0/1:63,2:0.0005:33,2


This will then output all lines matching both conditions:



awk -F"[  :]" '$15>0.06 && $19>0.001' file.txt
chr1 1641723 . TC T . . DP=59;ECNT=1;NLOD=2.40 GT:AD:AF:F1R2 0/1:30,2:0.089:12,4 0/1:30,2:0.0015:12,4





share|improve this answer





























    -1














    I have used below method to achieve the result



    for  i in `awk  '{print $NF}' file.txt | awk -F ":" '$3>"0.06"{print $0}'`; do awk -v i="$i" '$NF ==i{print $0}' file.txt ;done


    output



    chr1    1197592 .   C   A   .   .   DP=67;ECNT=1;NLOD=8.12  GT:AD:AF:F1R2   0/1:37,2:0.063:13,0
    chr1 1641723 . TC T . . DP=59;ECNT=1;NLOD=2.40 GT:AD:AF:F1R2 0/1:30,2:0.089:12,4
    [root@praveen_linux_example ~]#





    share|improve this answer





















      Your Answer








      StackExchange.ready(function() {
      var channelOptions = {
      tags: "".split(" "),
      id: "106"
      };
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function() {
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled) {
      StackExchange.using("snippets", function() {
      createEditor();
      });
      }
      else {
      createEditor();
      }
      });

      function createEditor() {
      StackExchange.prepareEditor({
      heartbeatType: 'answer',
      autoActivateHeartbeat: false,
      convertImagesToLinks: false,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: null,
      bindNavPrevention: true,
      postfix: "",
      imageUploader: {
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      },
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      });


      }
      });






      lindak is a new contributor. Be nice, and check out our Code of Conduct.










      draft saved

      draft discarded


















      StackExchange.ready(
      function () {
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f493204%2fawk-to-print-lines-in-file-with-multiple-delimiters%23new-answer', 'question_page');
      }
      );

      Post as a guest















      Required, but never shown

























      4 Answers
      4






      active

      oldest

      votes








      4 Answers
      4






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      3














      As soon as you start discarding data in a pipeline (which is what cut does), you can't get it back in a later stage of the same pipeline.



      Instead,



      $ awk 'split($10,a,":") && a[3] > 0.06' file
      chr1 1197592 . C A . . DP=67;ECNT=1;NLOD=8.12 GT:AD:AF:F1R2 0/1:37,2:0.063:13,0
      chr1 1641723 . TC T . . DP=59;ECNT=1;NLOD=2.40 GT:AD:AF:F1R2 0/1:30,2:0.089:12,4


      This takes the 10th whitespace-delimited field and splits it on colons into the array a. It prints the original line if the split() generated any elements in a and if the third element of a is greater than 0.06.



      If the fields in the file are tab-delimited and if any field contains spaces, then use -F 't' with awk to make sure that it finds the right fields correctly (the given example data does not have any such issues as far as I can see).





      Addressing the follow-up question in comments:



      awk 'split($10,a,":") && a[3] > 0.06 && split($11,b,":") && b[3] > 0.01' file





      share|improve this answer























      • Will it work also if i have a column 11 with similar info as in 10 to filter on them both simultaneously? E.g. to print only lines where value 3 in column 10>0.06 and value 3 in column 11>0.01. Something like: awk '(split($10,a,":") && a[3] > 0.06) && (split($11,b,":") && b[3] > 0.01)'
        – lindak
        2 hours ago












      • @lindak Yes, but the parentheses are optional there (unless you later want to change to (... && ...) || (... && ...)). See updated answer.
        – Kusalananda
        2 hours ago












      • Great, thank you!
        – lindak
        2 hours ago
















      3














      As soon as you start discarding data in a pipeline (which is what cut does), you can't get it back in a later stage of the same pipeline.



      Instead,



      $ awk 'split($10,a,":") && a[3] > 0.06' file
      chr1 1197592 . C A . . DP=67;ECNT=1;NLOD=8.12 GT:AD:AF:F1R2 0/1:37,2:0.063:13,0
      chr1 1641723 . TC T . . DP=59;ECNT=1;NLOD=2.40 GT:AD:AF:F1R2 0/1:30,2:0.089:12,4


      This takes the 10th whitespace-delimited field and splits it on colons into the array a. It prints the original line if the split() generated any elements in a and if the third element of a is greater than 0.06.



      If the fields in the file are tab-delimited and if any field contains spaces, then use -F 't' with awk to make sure that it finds the right fields correctly (the given example data does not have any such issues as far as I can see).





      Addressing the follow-up question in comments:



      awk 'split($10,a,":") && a[3] > 0.06 && split($11,b,":") && b[3] > 0.01' file





      share|improve this answer























      • Will it work also if i have a column 11 with similar info as in 10 to filter on them both simultaneously? E.g. to print only lines where value 3 in column 10>0.06 and value 3 in column 11>0.01. Something like: awk '(split($10,a,":") && a[3] > 0.06) && (split($11,b,":") && b[3] > 0.01)'
        – lindak
        2 hours ago












      • @lindak Yes, but the parentheses are optional there (unless you later want to change to (... && ...) || (... && ...)). See updated answer.
        – Kusalananda
        2 hours ago












      • Great, thank you!
        – lindak
        2 hours ago














      3












      3








      3






      As soon as you start discarding data in a pipeline (which is what cut does), you can't get it back in a later stage of the same pipeline.



      Instead,



      $ awk 'split($10,a,":") && a[3] > 0.06' file
      chr1 1197592 . C A . . DP=67;ECNT=1;NLOD=8.12 GT:AD:AF:F1R2 0/1:37,2:0.063:13,0
      chr1 1641723 . TC T . . DP=59;ECNT=1;NLOD=2.40 GT:AD:AF:F1R2 0/1:30,2:0.089:12,4


      This takes the 10th whitespace-delimited field and splits it on colons into the array a. It prints the original line if the split() generated any elements in a and if the third element of a is greater than 0.06.



      If the fields in the file are tab-delimited and if any field contains spaces, then use -F 't' with awk to make sure that it finds the right fields correctly (the given example data does not have any such issues as far as I can see).





      Addressing the follow-up question in comments:



      awk 'split($10,a,":") && a[3] > 0.06 && split($11,b,":") && b[3] > 0.01' file





      share|improve this answer














      As soon as you start discarding data in a pipeline (which is what cut does), you can't get it back in a later stage of the same pipeline.



      Instead,



      $ awk 'split($10,a,":") && a[3] > 0.06' file
      chr1 1197592 . C A . . DP=67;ECNT=1;NLOD=8.12 GT:AD:AF:F1R2 0/1:37,2:0.063:13,0
      chr1 1641723 . TC T . . DP=59;ECNT=1;NLOD=2.40 GT:AD:AF:F1R2 0/1:30,2:0.089:12,4


      This takes the 10th whitespace-delimited field and splits it on colons into the array a. It prints the original line if the split() generated any elements in a and if the third element of a is greater than 0.06.



      If the fields in the file are tab-delimited and if any field contains spaces, then use -F 't' with awk to make sure that it finds the right fields correctly (the given example data does not have any such issues as far as I can see).





      Addressing the follow-up question in comments:



      awk 'split($10,a,":") && a[3] > 0.06 && split($11,b,":") && b[3] > 0.01' file






      share|improve this answer














      share|improve this answer



      share|improve this answer








      edited 2 hours ago

























      answered 6 hours ago









      KusalanandaKusalananda

      123k16230376




      123k16230376












      • Will it work also if i have a column 11 with similar info as in 10 to filter on them both simultaneously? E.g. to print only lines where value 3 in column 10>0.06 and value 3 in column 11>0.01. Something like: awk '(split($10,a,":") && a[3] > 0.06) && (split($11,b,":") && b[3] > 0.01)'
        – lindak
        2 hours ago












      • @lindak Yes, but the parentheses are optional there (unless you later want to change to (... && ...) || (... && ...)). See updated answer.
        – Kusalananda
        2 hours ago












      • Great, thank you!
        – lindak
        2 hours ago


















      • Will it work also if i have a column 11 with similar info as in 10 to filter on them both simultaneously? E.g. to print only lines where value 3 in column 10>0.06 and value 3 in column 11>0.01. Something like: awk '(split($10,a,":") && a[3] > 0.06) && (split($11,b,":") && b[3] > 0.01)'
        – lindak
        2 hours ago












      • @lindak Yes, but the parentheses are optional there (unless you later want to change to (... && ...) || (... && ...)). See updated answer.
        – Kusalananda
        2 hours ago












      • Great, thank you!
        – lindak
        2 hours ago
















      Will it work also if i have a column 11 with similar info as in 10 to filter on them both simultaneously? E.g. to print only lines where value 3 in column 10>0.06 and value 3 in column 11>0.01. Something like: awk '(split($10,a,":") && a[3] > 0.06) && (split($11,b,":") && b[3] > 0.01)'
      – lindak
      2 hours ago






      Will it work also if i have a column 11 with similar info as in 10 to filter on them both simultaneously? E.g. to print only lines where value 3 in column 10>0.06 and value 3 in column 11>0.01. Something like: awk '(split($10,a,":") && a[3] > 0.06) && (split($11,b,":") && b[3] > 0.01)'
      – lindak
      2 hours ago














      @lindak Yes, but the parentheses are optional there (unless you later want to change to (... && ...) || (... && ...)). See updated answer.
      – Kusalananda
      2 hours ago






      @lindak Yes, but the parentheses are optional there (unless you later want to change to (... && ...) || (... && ...)). See updated answer.
      – Kusalananda
      2 hours ago














      Great, thank you!
      – lindak
      2 hours ago




      Great, thank you!
      – lindak
      2 hours ago













      3














      awk -F':' '$(NF-1) > 0.06 {print $0}' file


      Just use ':' as separator and evaluate the penultimate column






      share|improve this answer





















      • Thank you, it works for my example file, but my actual file has more columns which i never commented in the post, so my bad...
        – lindak
        5 hours ago
















      3














      awk -F':' '$(NF-1) > 0.06 {print $0}' file


      Just use ':' as separator and evaluate the penultimate column






      share|improve this answer





















      • Thank you, it works for my example file, but my actual file has more columns which i never commented in the post, so my bad...
        – lindak
        5 hours ago














      3












      3








      3






      awk -F':' '$(NF-1) > 0.06 {print $0}' file


      Just use ':' as separator and evaluate the penultimate column






      share|improve this answer












      awk -F':' '$(NF-1) > 0.06 {print $0}' file


      Just use ':' as separator and evaluate the penultimate column







      share|improve this answer












      share|improve this answer



      share|improve this answer










      answered 6 hours ago









      Emilio GalarragaEmilio Galarraga

      48929




      48929












      • Thank you, it works for my example file, but my actual file has more columns which i never commented in the post, so my bad...
        – lindak
        5 hours ago


















      • Thank you, it works for my example file, but my actual file has more columns which i never commented in the post, so my bad...
        – lindak
        5 hours ago
















      Thank you, it works for my example file, but my actual file has more columns which i never commented in the post, so my bad...
      – lindak
      5 hours ago




      Thank you, it works for my example file, but my actual file has more columns which i never commented in the post, so my bad...
      – lindak
      5 hours ago











      0














      Having read the comments it's clear that your sample data doesn't match your actual data (and it's using spaces instead of TABs to begin with, which means that even the command output of your own device won't work), but having clobbered together a different input file like so:



      cat file.txt
      chr1 1197592 . C A . . DP=67;ECNT=1;NLOD=8.12 GT:AD:AF:F1R2 0/1:37,2:0.063:13,0 0/1:37,2:0.0005:13,0
      chr1 1355707 . G T . . DP=69;ECNT=1;NLOD=4.51 GT:AD:AF:F1R2 0/1:50,3:0.059:20,3 0/1:50,3:0.0005:20,3
      chr1 1641723 . TC T . . DP=59;ECNT=1;NLOD=2.40 GT:AD:AF:F1R2 0/1:30,2:0.089:12,4 0/1:30,2:0.0015:12,4
      chr1 2550056 . TC CT . . DP=99;ECNT=1;NLOD=9.03 GT:AD:AF:F1R2 0/1:63,2:0.053:33,2 0/1:63,2:0.0005:33,2


      This will then output all lines matching both conditions:



      awk -F"[  :]" '$15>0.06 && $19>0.001' file.txt
      chr1 1641723 . TC T . . DP=59;ECNT=1;NLOD=2.40 GT:AD:AF:F1R2 0/1:30,2:0.089:12,4 0/1:30,2:0.0015:12,4





      share|improve this answer


























        0














        Having read the comments it's clear that your sample data doesn't match your actual data (and it's using spaces instead of TABs to begin with, which means that even the command output of your own device won't work), but having clobbered together a different input file like so:



        cat file.txt
        chr1 1197592 . C A . . DP=67;ECNT=1;NLOD=8.12 GT:AD:AF:F1R2 0/1:37,2:0.063:13,0 0/1:37,2:0.0005:13,0
        chr1 1355707 . G T . . DP=69;ECNT=1;NLOD=4.51 GT:AD:AF:F1R2 0/1:50,3:0.059:20,3 0/1:50,3:0.0005:20,3
        chr1 1641723 . TC T . . DP=59;ECNT=1;NLOD=2.40 GT:AD:AF:F1R2 0/1:30,2:0.089:12,4 0/1:30,2:0.0015:12,4
        chr1 2550056 . TC CT . . DP=99;ECNT=1;NLOD=9.03 GT:AD:AF:F1R2 0/1:63,2:0.053:33,2 0/1:63,2:0.0005:33,2


        This will then output all lines matching both conditions:



        awk -F"[  :]" '$15>0.06 && $19>0.001' file.txt
        chr1 1641723 . TC T . . DP=59;ECNT=1;NLOD=2.40 GT:AD:AF:F1R2 0/1:30,2:0.089:12,4 0/1:30,2:0.0015:12,4





        share|improve this answer
























          0












          0








          0






          Having read the comments it's clear that your sample data doesn't match your actual data (and it's using spaces instead of TABs to begin with, which means that even the command output of your own device won't work), but having clobbered together a different input file like so:



          cat file.txt
          chr1 1197592 . C A . . DP=67;ECNT=1;NLOD=8.12 GT:AD:AF:F1R2 0/1:37,2:0.063:13,0 0/1:37,2:0.0005:13,0
          chr1 1355707 . G T . . DP=69;ECNT=1;NLOD=4.51 GT:AD:AF:F1R2 0/1:50,3:0.059:20,3 0/1:50,3:0.0005:20,3
          chr1 1641723 . TC T . . DP=59;ECNT=1;NLOD=2.40 GT:AD:AF:F1R2 0/1:30,2:0.089:12,4 0/1:30,2:0.0015:12,4
          chr1 2550056 . TC CT . . DP=99;ECNT=1;NLOD=9.03 GT:AD:AF:F1R2 0/1:63,2:0.053:33,2 0/1:63,2:0.0005:33,2


          This will then output all lines matching both conditions:



          awk -F"[  :]" '$15>0.06 && $19>0.001' file.txt
          chr1 1641723 . TC T . . DP=59;ECNT=1;NLOD=2.40 GT:AD:AF:F1R2 0/1:30,2:0.089:12,4 0/1:30,2:0.0015:12,4





          share|improve this answer












          Having read the comments it's clear that your sample data doesn't match your actual data (and it's using spaces instead of TABs to begin with, which means that even the command output of your own device won't work), but having clobbered together a different input file like so:



          cat file.txt
          chr1 1197592 . C A . . DP=67;ECNT=1;NLOD=8.12 GT:AD:AF:F1R2 0/1:37,2:0.063:13,0 0/1:37,2:0.0005:13,0
          chr1 1355707 . G T . . DP=69;ECNT=1;NLOD=4.51 GT:AD:AF:F1R2 0/1:50,3:0.059:20,3 0/1:50,3:0.0005:20,3
          chr1 1641723 . TC T . . DP=59;ECNT=1;NLOD=2.40 GT:AD:AF:F1R2 0/1:30,2:0.089:12,4 0/1:30,2:0.0015:12,4
          chr1 2550056 . TC CT . . DP=99;ECNT=1;NLOD=9.03 GT:AD:AF:F1R2 0/1:63,2:0.053:33,2 0/1:63,2:0.0005:33,2


          This will then output all lines matching both conditions:



          awk -F"[  :]" '$15>0.06 && $19>0.001' file.txt
          chr1 1641723 . TC T . . DP=59;ECNT=1;NLOD=2.40 GT:AD:AF:F1R2 0/1:30,2:0.089:12,4 0/1:30,2:0.0015:12,4






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered 1 hour ago









          tinktink

          4,16211219




          4,16211219























              -1














              I have used below method to achieve the result



              for  i in `awk  '{print $NF}' file.txt | awk -F ":" '$3>"0.06"{print $0}'`; do awk -v i="$i" '$NF ==i{print $0}' file.txt ;done


              output



              chr1    1197592 .   C   A   .   .   DP=67;ECNT=1;NLOD=8.12  GT:AD:AF:F1R2   0/1:37,2:0.063:13,0
              chr1 1641723 . TC T . . DP=59;ECNT=1;NLOD=2.40 GT:AD:AF:F1R2 0/1:30,2:0.089:12,4
              [root@praveen_linux_example ~]#





              share|improve this answer


























                -1














                I have used below method to achieve the result



                for  i in `awk  '{print $NF}' file.txt | awk -F ":" '$3>"0.06"{print $0}'`; do awk -v i="$i" '$NF ==i{print $0}' file.txt ;done


                output



                chr1    1197592 .   C   A   .   .   DP=67;ECNT=1;NLOD=8.12  GT:AD:AF:F1R2   0/1:37,2:0.063:13,0
                chr1 1641723 . TC T . . DP=59;ECNT=1;NLOD=2.40 GT:AD:AF:F1R2 0/1:30,2:0.089:12,4
                [root@praveen_linux_example ~]#





                share|improve this answer
























                  -1












                  -1








                  -1






                  I have used below method to achieve the result



                  for  i in `awk  '{print $NF}' file.txt | awk -F ":" '$3>"0.06"{print $0}'`; do awk -v i="$i" '$NF ==i{print $0}' file.txt ;done


                  output



                  chr1    1197592 .   C   A   .   .   DP=67;ECNT=1;NLOD=8.12  GT:AD:AF:F1R2   0/1:37,2:0.063:13,0
                  chr1 1641723 . TC T . . DP=59;ECNT=1;NLOD=2.40 GT:AD:AF:F1R2 0/1:30,2:0.089:12,4
                  [root@praveen_linux_example ~]#





                  share|improve this answer












                  I have used below method to achieve the result



                  for  i in `awk  '{print $NF}' file.txt | awk -F ":" '$3>"0.06"{print $0}'`; do awk -v i="$i" '$NF ==i{print $0}' file.txt ;done


                  output



                  chr1    1197592 .   C   A   .   .   DP=67;ECNT=1;NLOD=8.12  GT:AD:AF:F1R2   0/1:37,2:0.063:13,0
                  chr1 1641723 . TC T . . DP=59;ECNT=1;NLOD=2.40 GT:AD:AF:F1R2 0/1:30,2:0.089:12,4
                  [root@praveen_linux_example ~]#






                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered 2 hours ago









                  Praveen Kumar BSPraveen Kumar BS

                  1,250138




                  1,250138






















                      lindak is a new contributor. Be nice, and check out our Code of Conduct.










                      draft saved

                      draft discarded


















                      lindak is a new contributor. Be nice, and check out our Code of Conduct.













                      lindak is a new contributor. Be nice, and check out our Code of Conduct.












                      lindak is a new contributor. Be nice, and check out our Code of Conduct.
















                      Thanks for contributing an answer to Unix & Linux Stack Exchange!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid



                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.


                      To learn more, see our tips on writing great answers.





                      Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                      Please pay close attention to the following guidance:


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid



                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.


                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function () {
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f493204%2fawk-to-print-lines-in-file-with-multiple-delimiters%23new-answer', 'question_page');
                      }
                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      Popular posts from this blog

                      Hivernacle

                      Fluorita

                      Hulsita