Hello All,
I am trying to find all the files on patterns that are to be taken as a user input. The number of user input pattern is not fixed. it can vary from 1 to as many as i would like. after i have taken all the user input i have to find the files based on these pattrens and store the file names in an array.since the number of input is not fixed so i thought best way is to use while loop to seperate the pattrens stored in the read variable . here is my code
Code:
declare -a arr
echo " enter the pattern/patterns ->" # entering the patterns. it can be 1 or more then one
read pattern #say the patterns entered are- file123 file124 file125
while IFS='' read -d '' var ; do # if there are more then one pattren then seperating the pattrens by IFS='' in a while loop
arr=$(find "/home/dir1/" -type f -name '$var*')#finding all the files on each pattren and storing it in array
done < < ( $pattern )
but somewhere i am making mistake.can anyone please help