Date: Sun, 23 Dec 2012 18:48:12 +0100 From: =?UTF-8?B?76O/IERow6luaW4gSmVhbi1KYWNxdWVz?= <dhenin@gmail.com> To: Polytropon <freebsd@edvax.de> Cc: FreeBSD Global Users Mailing List <freebsd-questions@freebsd.org>, Jack Mc Lauren <jack.mclauren@yahoo.com> Subject: Re: shell script problem Message-ID: <CAL5CjnzCrGfWg9Qeqnmk0H6=vt=-AQP1yNOP%2BHbkXfgWV6dXzQ@mail.gmail.com> In-Reply-To: <20121223104311.557f3752.freebsd@edvax.de> References: <1356253535.76738.YahooMailClassic@web160101.mail.bf1.yahoo.com> <20121223103434.def7cd9c.freebsd@edvax.de> <20121223104311.557f3752.freebsd@edvax.de>
next in thread | previous in thread | raw e-mail | index | archive | help
2012/12/23 Polytropon <freebsd@edvax.de> > > #!/bin/sh > > cat foo.txt | while read LINE1 > do > cat bar.txt | while read LINE2 > do > if [ "$LINE1" =3D "$LINE2" ]; then > sw=3D"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" =3D "0" ]; then > echo "DO SOMETHING!" > fi > sw=3D"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" =3D "$LINE2" ]; then echo 'ok' > $$tmp break fi done if [ `cat $$tmp` =3D "One" ]; then echo "One !" fi if [ `cat $$tmp` =3D "ok" ]; then echo "ok !" fi done Best regards --------------------------------------------------------- (=C2=B0> Dh=C3=A9nin Jean-Jacques / ) 48, rue de la Justice 78300 Poissy ^^ dhenin@gmail.com ---------------------------------------------------------
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAL5CjnzCrGfWg9Qeqnmk0H6=vt=-AQP1yNOP%2BHbkXfgWV6dXzQ>