Cutting string inside if

I was trying the below statement

        if [ "${FXML_line:1129:1}" = "S" -o "${FXML_line:1129:1}" = "H" ]

It is working fine if I run it in a test file.
but not working, when I am trying in my actual script.
Error:

 
: "${FXML_line:1129:1}": bad substitution

Thanks in advance :slight_smile:

PS: Above if block I have a while loop which is reading a file into FXML_line but while reading that file, it doesn't read <tab>
fo example if the line in the file is like "<tab>;<tab>;abcdefgh;123456" then it is reading "; ;abcdefgh;123456". What is the reason behind this behavior and how can I overcome this.

Please state what Operating System and version you are running and what Shell you are using. Because your syntax is unusual, please do this on every thread you open.

Please show the actual script with sample input data and expected output data.

Please explain what you expect from: ${FXML_line:1129:1}

This is Unix with Korn Shel and the command is used to cut 1130th character from a line. The command is working if I am using standalone but not inside the loop.

Though I have achieved that using awk but the reading of file by the loop is annoying. It is removing tabs in the line
for example:

    ;  ;COMP;         ;        ;                                                                ;

to:

; ;COMP; ; ; ; ;

Loop is like this:

       while read FXML_line
       do
       done < "${PREPAVAL_TRAVAIL}/${FXML_index}"

Please post the output from this command, blotting anything confidential like machine names with X's:

uname -a

Ps: I can only get your syntax to work in ksh93. It give syntax errors in normal ksh or a Posix Shell.
Do you know what Shell and version you have?

Thread closed, continue here:
http://www.unix.com/shell-programming-scripting/178603-whats-wrong-condition.html\#post302606233