1
F gge0006y

D 12-30-2006

T 14:05:55

S a69

B 15.3

M gge06001

P 30.6

Q 21.1

R 1006.6

U 1014.6

X 36.1

A 38.994        0             0

G 107.71        0             0

H 8.433

O 36.705

C 7.621

K 27.623

W 210.51

I need to cut the both 0 0 from A and G but I cant seem to do it without cutting all zeros from the text which is not what I want, just those four zeros, how would I do this?

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

1 Answer 1

0

Assuming input is space delimited:

cut -d' ' -f 1-2 input

(This answer is the same as steeldriver's prior comment...)

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.