If some text is like
cell (ABC)
(A1)
(A2)
function (A1.A2)
I want output as
cell ABC
A1
A2
function (A1.A2)
I want to remove bracket from each line of file except the present in function line. Using code
sed 's/[()]//g' file
Removes bracket from each line. How can I modify the above code to get desired output.
You can add a jump out condition to your sed command:
sed '/^function /b;s/[()]//g' file
Or, condition the substitute on not matching a function:
sed '/^function /!s/[()]//g' file
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With