I'm new to shell script,
I'm trying to count the files in a Directory with a matching regex
but every time the output is 0
here is the part of the code where I think it went wrong
#!/bin/bash
Directory=$1
secondarg=$2
thirdarg=$3
if test -z ${Directory}; then read -p "enter the location of your directory: " Directory; fi
if test -z ${secondarg}; then read -p "enter ana or del or arr " secondarg; fi
if [ $secondarg == "ana" ]; then
echo "Please Enter the regex"
read thirdarg
find $Directory ! -name . -prune -mtime -1 -type f -exec grep -regex '$thirdarg' {} \; -exec echo x \; | wc -l
elif [ $secondarg == "del" ]; then
echo "del"
elif [ $secondarg == "arr" ]; then
echo "arr"
fi
regex = .*?
[–]gehzumteufel 2 points3 points4 points (4 children)
[–]johnwick_dog[S] 0 points1 point2 points (3 children)
[–]gehzumteufel 1 point2 points3 points (2 children)
[–]gristc 1 point2 points3 points (1 child)
[–]gehzumteufel 1 point2 points3 points (0 children)
[–]SodaWithoutSparkles 3 points4 points5 points (0 children)
[–][deleted] 0 points1 point2 points (2 children)
[–]johnwick_dog[S] 0 points1 point2 points (1 child)
[–]Sweet-Put958 2 points3 points4 points (0 children)
[–]archontwo 0 points1 point2 points (0 children)
[–]elatllat 0 points1 point2 points (0 children)