Hello.
A_LIGNE="cnezJ,V ,FMZ fd,Mok CODKJ,F SOME_WORD fcnQ, VMQKV Q"
A_PATTERN="SOME_WORD"
sed 's/'$A_PATTERN'//g' <<< "$A_LINE"
will remove 'SOME_WORD' and give :
"cnezJ,V ,FMZ fd,Mok CODKJ,F fcnQ, VMQKV Q"
A_PATTERN="SOME_WORD[[:space:]]"
sed 's/'$A_PATTERN'//g' <<< "$A_LINE"
will remove 'SOME_WORD' and the space after it and give :
"cnezJ,V ,FMZ fd,Mok CODKJ,F fcnQ, VMQKV Q"
Now the question
--------------------------
My problem is that the pattern is at the beginning of the line
I would like to remove the whitespace before and after it.
I tried this :
A_PATTERN="[[:space:]]SOME_WORD[[:space:]]"
sed 's/'$A_PATTERN'//g' <<< "$A_LINE"
should remove 'SOME_WORD' and the space before and after it.
But it does not work.
The pattern is at the beginning of the line and have white space after it.
But may or may not have white space before it.
ps (I made a try on a file where the pattern start at the beginning of the line without white space before it.)
Any help is welcome