0

Let's say I have a file with many URLs:

http://foo.com/abc_(Programming_Language)
http://example.com/test)

I'd like to remove the trailing ) for each line in which there is no opening ( using sed and/or grep.

The result file should look like this:

http://foo.com/abc_(Programming_Language)
http://example.com/test

How can I do this?

1

I think this will do:

sed '/(.*)/! s/)$//' file 
0

I have done by below awk command

command

awk '$0 !~ /\(/{gsub(")","",$0);}1' filename

output

http://foo.com/abc_(Programming_Language)
http://example.com/test

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.