Can somebody please help me to remove the last character of a string.??
I have a string variable, in which I dynamically put values in a for loop.I want to remove the last character from the string.
But, the problem is I will not know which character can come in the string (Its inside for loop). So I tried using substr. substr does not work here.
Is there any alternative to do this?? Here my code goes.
....
for files in $rawSourceFiles
loop
MID_INFILE=`cat �${files}� | grep �Message-Id:"`
len=`expr �${MID_INFILE}� : �.*'`
len=`expr $len - 1`
trimmedMID_INFILE=`expr substr �${MID_INFILE}� 1 ${len}`
.....
...
done
But, it does not seem working. It throws an error �expr: syntax error� ..
What all I want here is in trimmedMID_INFILE should be the string MID_INFILE with last character trimmed. (last char could be anything like "\n", "/", etc.)
Can anybody please enlighten me?? I would be so grateful. Thanks in advance.