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*

4
  • probably has flaws but sed 's/ 0//g' input or sed 's/0 0//g' input <=SE removed the extra spaces in there. Commented Feb 11, 2018 at 18:30
  • 3
    What's the rule? "Remove columns 2 and 3 if they exist?" or " ... if they exist and are 0"? or "if they exist on lines where column 1 is an A or G"? Commented Feb 11, 2018 at 18:31
  • @cargoboom: Be wary of using my first suggestion. if any of your numbers start with a 0 it will give unwanted results. For example if you had: C 07.621 it would cut it to C 7.621 Commented Feb 11, 2018 at 18:39
  • 1
    Rather than cutting the fields you don't want, consider printing the fields that you do e.g. cut -d ' ' -f1,2 file or awk '{print $1, $2}' file Commented Feb 11, 2018 at 19:43