HopeLessGuy
Technical User
(Korn Script on Sun Solaris)
I currently have a while loop which reads the file till EOF. The file contains file names that are to be searched. In the while statement, I noticed that korn shell does not treat the pipe, | , as it original is used.
For example -
while read tmpFiles
do
i=$i+1
tmpArray=$tmpFiles
fName="${tmpArray}"
grep -c "yo" ${fName%% *} | awk -F: '$2 == 3 { print $1 }'
done < "tmpList.dat"
That's just rushed code, shouldn't be taken into account But I noticed, that while the loop executes. It will read the right side of the pipe ( | ) then read "tmpList.dat" then read the left side of the ( | ). Therefore the awk is useless since it doesn't receive the exact information from grep due to the order of execution. If I were to use the grep | awk out of the loop, it works. Any ideas?
Edit - I originally posted this in the Sun - Solaris Forum... had no clue there was a Unix Scripting Forum.
I currently have a while loop which reads the file till EOF. The file contains file names that are to be searched. In the while statement, I noticed that korn shell does not treat the pipe, | , as it original is used.
For example -
while read tmpFiles
do
i=$i+1
tmpArray=$tmpFiles
fName="${tmpArray}"
grep -c "yo" ${fName%% *} | awk -F: '$2 == 3 { print $1 }'
done < "tmpList.dat"
That's just rushed code, shouldn't be taken into account But I noticed, that while the loop executes. It will read the right side of the pipe ( | ) then read "tmpList.dat" then read the left side of the ( | ). Therefore the awk is useless since it doesn't receive the exact information from grep due to the order of execution. If I were to use the grep | awk out of the loop, it works. Any ideas?
Edit - I originally posted this in the Sun - Solaris Forum... had no clue there was a Unix Scripting Forum.