I have a bash script, it works on CENTOS fine, but when I want to run the script on Red Hat Enterprise Linux, I got the following error.
if [ "${line:(-2)}" == "nm" ]
then
sub_sh=${line:31:8}
if [ $sub_sh != "test" ];
then
sub_str=${line:0:10}
date_line=$(date --date=$sub_str '+%Y%m%d')
result=`expr $date_line - $yesterday`
if [ $result -gt 1000 ];
then
Rtime="${line##* }"
pureqrt=${Rtime::-2} #line 56
Error:
line 56: -2: substring expression < 0
I used the below script to remove the two last characters
# in bash
# pureqrt=${queryRtime::-2}
pureqrt=$(echo $queryRtime | cut -d "m" -f 1)
----------------------------------------------
#command line
echo "2234ms" | cut -d "m" -f 1
output : 2234
I appreciate your help