shell script problem
Dhénin Jean-Jacques
dhenin at gmail.com
Sun Dec 23 17:48:53 UTC 2012
2012/12/23 Polytropon <freebsd at edvax.de>
>
> #!/bin/sh
>
> cat foo.txt | while read LINE1
> do
> cat bar.txt | while read LINE2
> do
> if [ "$LINE1" = "$LINE2" ]; then
> sw="1"
> echo "Current value of sw is : " $sw
>
* ps -l | grep $$ *
# see subshell here
> break
> fi
> done
>
* echo " Process: " $$*
# And the parent
> echo "Value of sw is : " $sw
> if [ "$sw" = "0" ]; then
> echo "DO SOMETHING!"
> fi
> sw="0"
> done
>
I suggest :
-----------------%><-------------------------------------
#!/bin/sh
cat foo.txt | while read LINE1
do
echo 'One' > $$tmp
cat bar.txt |while read LINE2
do
if [ "$LINE1" = "$LINE2" ]; then
echo 'ok' > $$tmp
break
fi
done
if [ `cat $$tmp` = "One" ]; then
echo "One !"
fi
if [ `cat $$tmp` = "ok" ]; then
echo "ok !"
fi
done
Best regards
---------------------------------------------------------
(°> Dhénin Jean-Jacques
/ ) 48, rue de la Justice 78300 Poissy
^^ dhenin at gmail.com
---------------------------------------------------------
More information about the freebsd-questions
mailing list