LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   for loop only works properly on first loop (https://www.linuxquestions.org/questions/programming-9/for-loop-only-works-properly-on-first-loop-396514/)

symo0009 12-25-2005 04:52 PM

for loop only works properly on first loop
 
in the following batch file the for loop performs the correct function on the first loop and then on the following loops it will only echo $entry... how do i make it output
`pwd`/"$entry"
every time it loops?


SCRIPT-------------------

for entry in "`cat list1.list`"
do

echo `pwd`/"$entry"

done


OUTPUT-------------------

/mnt/sda5/music/"song 1"
"song 2"
"song 3"
"song 4"
"song 5"

Hko 12-25-2005 05:17 PM

Code:

#!/bin/bash

while read entry ; do
    echo $PWD/"$entry"
done <list1.list



All times are GMT -5. The time now is 10:28 AM.