Issue
String:
@btbtbtbr@
Desired Output:
@btbtbtbr
Is there any regex to use grep to extract @btbtbt@ from file. Or sed to convert it My file has multiple occurences of words between two @ and want to replace word with itself but removing second @
Tried Below command but failed
grep '@.*@' -o | sed 's/.$//g'
grep -Po '(?<=(@ )).*(?= @)' | sed 's/.$//g'
sed -e 's/.*@\(.*\)@.*/\1/'
Solution
You may try using the pattern (@.*?)@
and then replace with just the first capture group:
echo "@btbtbtbr@" | sed -rn 's/(@[^@]+)@/\1/p'
Answered By - Tim Biegeleisen