Skip to main content
Tweeted twitter.com/#!/StackUnix/status/53972114658701313
edited tags
Link
Gilles 'SO- stop being evil'
  • 865.4k
  • 205
  • 1.8k
  • 2.3k
added extra information
Source Link
Azim
  • 133
  • 1
  • 5

In a BASH shell, I would like to take the lines of a file (eg pattern.txt) and find the files on my system whose names contain the patterns in each line of my file. So, I have the following for loop

for pp in `cat pattern.txt`; do find ./ -iname "*${pp}*" -print0; done

which doesn't find any files when if the first line in pattern.txt doe exist. So how can I fix the above command line?

Note: Each line in my file contains characters [a-zA-Z] only.

In a BASH shell, I would like to take the lines of a file (eg pattern.txt) and find the files on my system whose names contain the patterns in each line of my file. So, I have the following for loop

for pp in `cat pattern.txt`; do find ./ -iname "*${pp}*" -print0; done

which doesn't find any files when if the first line in pattern.txt doe exist. So how can I fix the above command line?

In a BASH shell, I would like to take the lines of a file (eg pattern.txt) and find the files on my system whose names contain the patterns in each line of my file. So, I have the following for loop

for pp in `cat pattern.txt`; do find ./ -iname "*${pp}*" -print0; done

which doesn't find any files when if the first line in pattern.txt doe exist. So how can I fix the above command line?

Note: Each line in my file contains characters [a-zA-Z] only.

Source Link
Azim
  • 133
  • 1
  • 5

How can I loop through lines of a file and find files matching each line?

In a BASH shell, I would like to take the lines of a file (eg pattern.txt) and find the files on my system whose names contain the patterns in each line of my file. So, I have the following for loop

for pp in `cat pattern.txt`; do find ./ -iname "*${pp}*" -print0; done

which doesn't find any files when if the first line in pattern.txt doe exist. So how can I fix the above command line?