I'm using a little code to check if some files match with each other or not then prompt a question to the user and take appropriate actions according to the user response. However, bash completely ignores my read command!
declare -i int
int=1
find ./1 -name '*.xyz' | while read FILENAME
do
find . -name '*.xyz' | while read FILENAME2
do
if [ $FILENAME != $FILENAME2 ]; then
if [ $(dirname "${FILENAME}") != $(dirname "${FILENAME2}") ]; then
if [ $(basename "${FILENAME}") == $(basename "${FILENAME2}") ]; then
int=int+1
if cmp -s "$FILENAME" "$FILENAME2" ; then
echo "Match", "$FILENAME", "$FILENAME2", "$int"
else
# echo "No Match", "$FILENAME", "$FILENAME2", "$int"
read -p "No match modify? (y/n)" d
echo "$d ";
fi
if [ "$int" -gt 44 ]; then
exit 1
fi
fi
fi
fi
done
done
I am using osx. I have checked and a simple read command functions properly outside a loop on my terminal(iterm).
#!/usr/bin/env bash.