Codeschnipsel – check if File exist with list

Just a small script which checks for the existence of files. I use it on restore operations.

#!/bin/bash

while IFS= read -r f; do
    if [[ ! -f $f ]]; then
        printf 'File missing: %s\n' "$f"
#    else
#        printf 'File exists:  %s\n' "$f"
    fi
done < "$1"

The list of files to check with absolute paths.

/home/user1/file_1
/home/user1/file_2
...
/home/user1/file_n

Let’s run the script:

[user1@server1 ~]$ ./checkFileExists.sh fileList 

    File missing:    /app/perl5/lib/IO/Formatter.pm