sed: -e expression #1, char 24: Invalid range end
It was nice experience to work on this kind of error( error : “sed: -e expression #1, char 24: Invalid range end “)
I made a bash script having expect command in it.
I was passing variable value from my mysql DB into the bash script.
The output which was coming from mysql was appearing like this —
| id |
| 351 |
The problem was coming because the sed command which I 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.
The +sign was not normal keyboard input + sign .It seems it was different special character.
The solution come when I used the below tr command in my bash script.Just have a look —
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 I did ,is not same with every such error. It is just a one more reason.