Dear Friends,
Regarding Compilation error character is missing-unix shell script
I am new to unix shell script.
My requirement is --I need to find out 3 files in my UBM unix directory,if any one(CMUSER) file is available means,then i need to exit from my unix script,
Below is my unix shell script logic and need to check with you guys why I am getting compilation error( mentioned all details). please answer specific to my question..
cd /$UBCS
if [ -f /$UBM/CSUSER.LOCKED -o -f /$UBM/CSUSER.START]
-o f /$UBM/CSUSER.UPDATE ];
then
exit;
fi
my compilation error below
Enter script to execute: atm-autopbf
/rd23/gilbat/R2016/ubcs/atm-autopbf[38]: test: 0403-021 **A ] character is missing**
.
/rd23/gilbat/R2016/ubcs/atm-autopbf**[39]: -o: **not found.****
Not running C/S (SHELMATE MAXSESSIONS=0). Aborting ...
Press <ENTER> to continue:
There are several things:
- There should be a space before the closing
]
, anyway it should not be there
- A minus sign is missing before
-f
- The last part is on a new line, so it either should be one line above or the should be a backslash as the last character on the line before
--
Note: The use of -o
in test commands is deprecated. Consider using something like:
if
[ -f "/$UBM/CSUSER.LOCKED" ] ||
[ -f "/$UBM/CSUSER.START" ] ||
[ -f "/$UBM/CSUSER.UPDATE" ]
then
The reason the [
and ]
characters have be set apart is that they are actually commands in terms of how the shell interprets them. Like awk
or find
.
For example on most systems if you use ls
to list files in your /bin directory
$ ls -l /bin/[
-rwxr-xr-x 1 Owner None 64019 Dec 16 15:54 '/bin/['
You will see a file that is named [
. Weird, I know, but it is a command and needs spaces around it like any other self-respecting word.