Search code examples
bashif-statementsyntaxunary-operator

Multiple unary operators in an if statement


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

Solution

  • if [ -f "file1" -a -f "file2" -a "file3" ]; then
       #some code
    fi