From owner-freebsd-questions@FreeBSD.ORG Sun Dec 23 17:48:53 2012 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 7762F933 for ; Sun, 23 Dec 2012 17:48:53 +0000 (UTC) (envelope-from dhenin@gmail.com) Received: from mail-ie0-f173.google.com (mail-ie0-f173.google.com [209.85.223.173]) by mx1.freebsd.org (Postfix) with ESMTP id 350678FC0A for ; Sun, 23 Dec 2012 17:48:53 +0000 (UTC) Received: by mail-ie0-f173.google.com with SMTP id e13so8293855iej.32 for ; Sun, 23 Dec 2012 09:48:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=hKxy69oLFnokmvug8YrqcAWBKJlUFq1q0C6fUFXL8YY=; b=vSZNv8bs3/m2zo+6py/bGXiL8TFo52gGP2NDoUPv9S9KpG9jtHsyemjJhhc6oNzWBp snFvdNmCrPRINmlWJno9TcHxJncWGAiDy8awp8mXa/rlzgHihoNwwOAA2J97zis5XFWi PHblW8QUw+y4+qAlhDainuZBDKMbemNeBUcgJStCdVQnem0wxBfVM9ZCGhf5cnLEkEo6 Bv/6Sy2zs5cmTRFdFITYV01sf2Qac0O7bylWXbire+95p3oGekdvf8CZUCJmyKACVUC7 fTp+1xKHc8nxbJo6AJ9mSGJ9tT1vEXqn+fJ3sBHXsr+0kobhzouiwPpSEE3m6LKHd/Bt 0Wow== Received: by 10.50.152.240 with SMTP id vb16mr12984368igb.90.1356284932666; Sun, 23 Dec 2012 09:48:52 -0800 (PST) MIME-Version: 1.0 Received: by 10.64.24.229 with HTTP; Sun, 23 Dec 2012 09:48:12 -0800 (PST) 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> From: =?UTF-8?B?76O/IERow6luaW4gSmVhbi1KYWNxdWVz?= Date: Sun, 23 Dec 2012 18:48:12 +0100 Message-ID: Subject: Re: shell script problem To: Polytropon Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Content-Filtered-By: Mailman/MimeDel 2.1.14 Cc: FreeBSD Global Users Mailing List , Jack Mc Lauren X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 23 Dec 2012 17:48:53 -0000 2012/12/23 Polytropon > > #!/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 ---------------------------------------------------------