I'm working on Aix 6.1 and using ksh shell.
The below works fine on Linux bash or ksh shell [tested both].
while IFS= read -r dirpath ; do
echo "Hi"
done <<<"$var"
However, any such while loop that reads the input from file or variable using <<<
fails on Aix system with the below error:
Below are the different while loops each having <<< for file input:
while IFS='\n' read -r line; do
while read -r line; do
Can someone please suggest what works for ksh on AiX 6.1 ?
ksh does not have the <<<
(here string) operator. (An exception are few variants of ksh93.)
In ksh you can do
echo "$var" |
while IFS= read -r dirpath
do
echo "Hi"
done
Note that ksh, unlike other shells, runs the last part of a pipe in the main shell. For ex
count=0
echo "$var" |
while IFS= read -r dirpath
do
echo "Hi"
(( count+=1 ))
done
echo $count
Other shells run it in a sub shell, so the $count updates are gone when back in the main shell.
1 Like
@MadeinGermany: I love your answers !! They are precise
Works fine. I will test more conditions shorlty.
1 Like
system
Automatically bumped
4
Moderator comments were removed during original forum migration.