While working on sed command stricken with this, error : “sed: -e expression #1, char 24: Invalid range end “). To solve this problem, we have used sed and tr command.
The problem was coming because the sed command which we used was giving right output i.e 351 only in terminal.
But in my bash script variable it seems it was also taking some other unknown characters or spaces.
Here the plus(+) sign is a special character.
The solution come when we used the below
tr command in our bash script. It has trimmed the special character from the output which we got from mysql command.
ID=`mysql -uUsername -pPASSWORDXXX -e "select id from databasename.tablename where name = ''linuxtribe"| sed -e 's/[!@#$%^&*()]//g'|sed '1d'|tr -cds "[:alnum:]" "[ ]"`
The troubleshooting which we did ,is not same with every such error.