I struggle with the examples given if a file exists. I want to check if multiple files exists in order to perform further operations.
ls -al:
-rwxrwxrwx 1 root tomcat 6 Dec 16 11:25 documents_2019-12-12.tar.gz
echo < [ -e ./documents_2019-12-12.tar.gz ]:
bash: [: No such file or directory
Can somebody tell me what i'm doing wrong?
Edit: I have a backup direcory with two files:
database_date.sql
documents_date.tar.gz
I need to check if both files for a given date are available. The directory shall contain these file-pairs for several dates.
echo
command. Do you mean something like[ -e ./documents_2019-12-12.tar.gz ] && echo "file exists"
? You can combine multiple checks, e.g.[ -e file1 ] && [ -e file2 ] && [ -e file3 ] && echo "all files exist"
for i in /my/path/files.*; do test -f "$i" && echo "exists one or more files" && break; done
. See this thread for explanations