Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

14
  • 1
    Why not just parse the TSV directly? awk -F '\t' will separate input fields by tabs. And indeed by default awk will separate fields by coniguous whitespace. So to get all blue-eyed people (and preserve the header), you just need awk -F '\t' 'BEGIN { OFS="\t" } NR==1 { print } NR>1 && $3 = "Blue" { print }'. Commented Aug 4, 2020 at 20:41
  • I tried running this command on a sample file called "test.tsv", with the same input as listed above, however it produced an unusual output. It just replaced all of the Eye Colors with "Blue" while everything else stayed the same. Commented Aug 4, 2020 at 21:03
  • $3 = "Blue" should be $3 == "Blue". The former is an assignment, the latter is a comparison. Commented Aug 4, 2020 at 21:11
  • Is this a CSV or TSV? Commented Aug 4, 2020 at 22:19
  • 1
    Dishing out the information about your requirements a breadcrumb at a time isn't a good approach to getting a good solution. Please edit your question to provide a more truly representative example of what it is you're trying to do. Include a TSV file, a CSV file, and the expected output files you expect given that as input. Make sure you cover all your use cases, e.g. whether all matches are against values in 1 column or different matches in different columns, etc. See How to Ask. Commented Aug 4, 2020 at 22:47