1

Somehow in the following script, value of $i
is not expanded on line 3. Any idea why?

for i in `cat test.txt`
do
        for j in `find . -name $i`
        do
                echo $j
        done
done
simplfuzz
  • 12,479
  • 24
  • 84
  • 137

2 Answers2

2

After you fix the line endings:

xargs --arg-file test.text -I % find . -name "%"

No need for nested loops.

Dennis Williamson
  • 346,391
  • 90
  • 374
  • 439
0
for i in `cat test.txt | sed -e "s/\r//g"`; do find -name $i; done

big question: cygwin support sed?

or cygwin

d2u test.txt; for i in `cat test.txt`; do find -name $i; done

or linux

dos2unix test.txt; for i in `cat test.txt`; do find -name $i; done
ajreal
  • 46,720
  • 11
  • 89
  • 119