Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Bash script to check files in list exist in directory
#!/usr/bin/env bash
#Check Files in list from file exist or doesn't exist in directory.
if [ $# -eq 0 ] || [ $# -eq 1 ]
echo "You must pass the path to file with the list and the path to directory to check files. \nsh path/to/file path/to/directory"
exit 1
while read -r file; do
if [ -e "$2/$file" ]; then
echo "$file exists in $2"
echo "$file doesn't exist in $2"
done < "$1"

This comment has been minimized.

Copy link

AruniRC commented Aug 9, 2018

This is such a handy script! Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.