How do I remove parentheses using sed?
input (192.168.1.1)
output 192.168.1.1[COLOR="\#738fbf"]
How do I remove parentheses using sed?
input (192.168.1.1)
output 192.168.1.1[COLOR="\#738fbf"]
echo '(192.168.1.1)' | sed 's/)//;s/(//'
echo '(192.168.1.1)' | sed 's/[()]//g'
Thanks guys, but I have a problem using this in awk code, is there a way to pass this in a print statement in awk?
For example
awk '{
if ($1 ~ "^[(0-9]+\.[0-9]+\.[0-9]+\.[0-9)]+$" )
{print `sed "s/[()]//g"`'${1}'}
}'
The above code does not work. Basically the logic checks to see if the first field in a txt file is an ip then print out the ip stripping the parantheses.
Thanks!
echo '(192.168.1.1)' | nawk 'match($1, "^[(0-9]+\.[0-9]+\.[0-9]+\.[0-9)]+$") {print substr($1,RSTART+1,RLENGTH-2)}'