I have string "[9920380315,POSTPAID,0009,646.26,SELF,APPLICATION]"
in that I want to remove first "[" but unable to do this using below command,
sed 's/[//g' Try doing this :
sed 's/\[//' The [ ] are special metacharacters used to match a character from a set (like [a-z]).
[ without the escape character :) sed: -e expression #1, char 5: unterminated s' command` s. I had asked a question here a few days back unix.stackexchange.com/questions/168240/… [ start cmd:> echo "[9920380315,POSTPAID,0009,646.26,SELF,APPLICATION]" | sed 's/[[]//' 9920380315,POSTPAID,0009,646.26,SELF,APPLICATION] This would help you,
$ echo '[9920380315,POSTPAID,0009,646.26,SELF,APPLICATION]'|sed 's/^\[//' 9920380315,POSTPAID,0009,646.26,SELF,APPLICATION] or directly with bash
code="[9920380315,POSTPAID,0009,646.26,SELF,APPLICATION]" echo "${code/[/}" sedcommand, this will only remove the first occurrence of [, use // I got a single pass to work to remove both [ AND ] using a combined sed expression which I had not considered before with 2 expressions separated with a semicolon :
$ echo "ON bec.[BusinessID] = s.[BusinessID]" | sed 's/\[//g; s/\]//g' ON bec.BusinessID = s.BusinessID tr -d '[]'. Also note that the request was for removing the first [ only. sed 's/[][]//g', which was already given as an answer. Also, FYI, you can do s/]// without escaping the ]. or
$ echo "[HTML],[FLASK]"|sed 's/[][]//g' HTML,FLASK [.
tr -d '['(assuming a POSIXtr).