Shell grammar question: logical OR in test

Hi,
I am trying to check if two input files exist before the rest of the scripts is run. Following is the code that I have but it gives me syntax error.

if [ ! -f /lv8/diamond/shprod/data/hcfadata.dat || ! -f /lv8/diamond/shprod/data/PDPhcfadata.dat  ]
then
echo "File not found"
else
echo "File found"
fi

try with [[ ]]

if [[ ! -f /lv8/diamond/shprod/data/hcfadata.dat || ! -f /lv8/diamond/shprod/data/PDPhcfadata.dat  ]]
if [ ! -f /lv8/diamond/shprod/data/hcfadata.dat ] || [ ! -f /lv8/diamond/shprod/data/PDPhcfadata.dat ]
[ ! -f /lv8/diamond/shprod/data/hcfadata.dat -o ! -f /lv8/diamond/shprod/data/PDPhcfadata.dat  ]

or:

[ ! -f /lv8/diamond/shprod/data/hcfadata.dat ] || [ ! -f /lv8/diamond/shprod/data/PDPhcfadata.dat  ]

or (not standard):

[[ ! -f /lv8/diamond/shprod/data/hcfadata.dat || ! -f /lv8/diamond/shprod/data/PDPhcfadata.dat  ]]
1 Like