I have a line
file="this-is-a-{test}file"
I want to remove {test} from this line. I used
{test}
echo $file | sed 's/[{][^}]*//'
but it brought me back
this-is-a-}file
How can I delete } too?
}
thank
You can use sed with the correct regex:
sed
s="this-is-a-{test}file" sed 's/{[^}]*}//' <<< "$s" this-is-a-file
Or this awk:
awk -F '{[^}]*}' '{print $1 $2}' <<< "$s" this-is-a-file
Also try using bash only oneliner as an alternative:
s="this-is-a-{test}file" echo ${s/\{test\}/}