Question

All,

At the start of my shell script I set a variable called filespresent="false"

This variable acts as a flag to indicate later in my shell script logs if it found a file to process through SQLLoader

The problem is that my if statement is not working it is giving the following error

[false: not found

Here is my code

if ["$filespresent" == "false"]
then
    echo ">>>No CSV files in : " $inbox " folder, skipped SQLLoader" >> script.log
fi

I checked the string comparison tutorial here, perhaps Solaris is different to Linux? http://www.tech-recipes.com/rx/209/bournebash-shell-scripts-string-comparison/

Was it helpful?

Solution

You need spaces around [ and ]. Say:

if [ "$filespresent" == "false" ]

[ is a command. Saying ["$filespresent" causes the shell to interpret it as one token and not a command.


The == operator is not available in sh, use = instead:

if [ "$filespresent" = "false" ]
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top