How to check more than 1 file specified files exists?

Hi all,

One of my script crated created 2 files in a dirs Output.log and Output.tmp . Now in another script i need to check if both of the above mentioned files are present in a directory or not.

I know to check one file [ -e /$path/Output.log ] but need to check both the files.

Anyone could please tell me how to do that?

thanks
--girija

Hi,
You can check as [ -e /$path/Output.log -a -e /$path/Output.tmp ]

Regards.

1 Like

what about or condition? how check if /$path/Output.log or -e /$path/Output.txt exists in a dir.

The use of -a and -o for testing is deprecated, and discouraged for divers reasons.

If your shell supports it, use:

[[ -e /$path/Output.log && -e /$path/Output.tmp ]]
[[ -e /$path/Output.log || -e /$path/Output.tmp ]]

If your shell does not support the double [[ , use single [ in this manner:

[ -e /$path/Output.log ] && [ -e /$path/Output.tmp ]
[ -e /$path/Output.log ] || [ -e /$path/Output.tmp ]
1 Like