Last active
May 1, 2020 22:00
-
-
Save xnumad/074bc4373a547f52eecb23a0f7ea2f06 to your computer and use it in GitHub Desktop.
Check if files in list (TXT) do exist (and which files don't exist)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
input="$1" #The file to read from given as first argument | |
#File content looks like this: | |
#/a.txt | |
#/subdir/b.txt | |
#File needs to have a newline at the end to have the last line processed! | |
while IFS= read -r line #Repetitively read lines | |
do | |
line=$(echo "$line"|tr -d '\r') #remove \r character | |
line=$(echo "$line"|tr -d '\n') #remove \n character | |
#https://mywiki.wooledge.org/BashFAQ/089 if you run another command here | |
if [[ ! -f ".$line" ]]; then #if file at .$line (dot for current directory) does not exist, then | |
echo "$line" #output the path of the missing file | |
fi #end of "if branch" | |
done < "$input" #Give while loop an input value |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Bash Shell Batch "DNS NXDOMAIN Check" and dirty output
Replace if branch with:
host -t ns "$line" | grep NXDOMAIN
Bash Shell Batch "DNS NXDOMAIN Check" and direct removal of line in file
Replace if branch with: