help to delete brackets [ ]

hi all,

i want to delete brackets in all the file and to keep the string or data between them ( example Q[xxxx] --> Qxxx) with sed command..

thanks

You could try tr:
e.g.

 echo "Q[xxxx]" | tr -d "[]"

or

echo "Q[xxxx]" < file

The brackets can be removed like any other character but have to be escaped because they have a special meaning to sed: "\[" will tell sed to treat the left bracket just as that character and with now special meaning at all. (Btw. the same is true for any other character with a special meaning, or "metacharacter" as is the correct denomination of these characters, too. "\*" will be an asterisk and not the wildcard, etc.).

Therefore your sed script is

sed 's/\[//g;s/\]//g' /path/to/file

It is possible to write that even shorter: you can use the bracket-construction itself, observe, that inside brackets metacharacters lose their meanings automatically so you don't even have to escape them:

sed 's/[[]]//g' /path/to/file

bakunin

thanks but
i need a command for all the file cause a have many cases like Q[xxx]...

for i in $(ls /path/to/files*)
do
    sed 's/\[//;s/\]//' $i
done