I have mutliple strings in very similar format.
(#1111111)
(#4444444)
I was trying to use sed to provide an output:
1111111
4444444
I have tried:
sed 's/(#[0-9]+)/^[0-9]+/g'
which seems to match ok, but the replace is not working.
I have mutliple strings in very similar format.
(#1111111)
(#4444444)
I was trying to use sed to provide an output:
1111111
4444444
I have tried:
sed 's/(#[0-9]+)/^[0-9]+/g'
which seems to match ok, but the replace is not working.
Given the format that you have in the question, there are two ways that this can be done:
sed 's/.*#\(.*\))/\1/' file
That will print everything between # and whatever comes before it which, in this case, is (, and ).
This can also be done:
sed -e 's|^(#||g' -e 's|)$||g' file
That will remove (# from the beginning of the string and ) from the end.
Output:
1111111
4444444
If it's a file, then you can add -i after sed to edit it in place. For stdout, pipe the command providing it into sed.
If this is a file or other output and there are differences, then you'll have to adjust the commands. I'm only operating on what you've provided in the question.