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?
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.
Sign up to join this communityI 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?
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