Multiple unary operators in an if statement

Kiran picture Kiran · Feb 22, 2010 · Viewed 14.9k times · Source

Is it possible to have multiple unary operators in if statements.. Here is the code snippet which is giving me error.

Please correct the code here.

if [ -f $input_file ] -a [ -f $output_file ] -a [ -f $log_file ] ]
then
    ### Some Code here
fi

Answer

ghostdog74 picture ghostdog74 · Feb 22, 2010
if [ -f "file1" -a -f "file2" -a "file3" ]; then
   #some code
fi