0

I have file with lines like that:

90 (160/180)

I need to delete text in () including the ().

Output should be: 90

This lines have different numbers, for example:

88 (155/190),
47 (143/188)

How i can do it with sed?

1

1 Answer 1

1

sed 's/ .*//' would delete everything after the first space (before the parenthesis and onwards), and sed 's/ ([^)]*)//' would delete only the parenthesis and the preceding space (the expression ([^)]*) matches a left parenthesis followed by any string not containing a right parenthesis, and then a right parenthesis).

Testing:

$ sed 's/ .*//' <<<"90 (160/180)"
90
$ sed 's/ ([^)]*)//' <<<"90 (160/180)"
90

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .