Dear All,
I have problem with generalizing my code and I can't see where the problem is.
I have a main.txt file that has all the information and then I have 4 folders (headoffice, branch, management, office) that each have a 2 of files keep.txt and throw.txt and each of them have few lines (so 4 keep and 4 throw)
I wrote a line that goes throw each line a main.txt and it creates a file with only lines that has an object name that is on the keep and not on the throw for the headoffice
grep -F -f headoffice/keep.txt main.txt | grep -v -F -f headoffice/throw | sort -u > result/headoffice-keep.txt
my problem is when I want to create a loop around it to take all the folders together as it gives me the wrong answer and I can't see why... tried millions of ways and one of them is the following
mkdir result
FILES="folder/*/*"
for W in $FILES
do
doc=$(basename $W)
mkdir result/${doc}
grep -F -f */*/keep.txt main.txt | grep -v -F -f */*/throw.txt | sort -u > result/${doc}/${doc}-keep.txt
done
Can someone help me plz:confused: