how can I search the contents of a directory for a string within a certain file that matches the name of a text file within the directory? And if the file within the directory is matched by the string, then move that file into a new directory.
So for example:
I have a text file like this:
Quote:
example_Name
test
helloWorld
blahblah23
|
and in a directory I have a long list of files (~14,000) that looks like this:
Quote:
example_Name.txt
test.txt
helloWorld.txt
example1.txt
example.txt
ect.txt
blahblah23.txt
..
..
...
|
Therefore, the output should
Quote:
example_Name.txt
test.txt
helloWorld.txt
blahblah23.txt
|
so far, I have this:
Code:
while read A B; do grep -r $A *.txt | mv ../newDir; done < ../f2 > ../f2.out
but I am not sure this will work... I am also getting this error
Quote:
-bash: /bin/grep: Argument list too long
|
Any idea how to fix this or come up with a code that works?