From owner-freebsd-questions Wed Feb 7 12:26:35 2001 Delivered-To: freebsd-questions@freebsd.org Received: from FreeBSD.mine.nu (unknown [203.106.71.238]) by hub.freebsd.org (Postfix) with ESMTP id 2FC5837B401 for ; Wed, 7 Feb 2001 12:26:13 -0800 (PST) Received: from FreeBSD.mine.nu (-@localhost [127.0.0.1]) by FreeBSD.mine.nu (8.8.8/8.8.8) with SMTP id EAA25982; Thu, 8 Feb 2001 04:39:10 +0800 (MYT) (envelope-from skywizard@time.net.my) From: Ariff Abdullah Reply-To: skywizard@time.net.my Organization: FreeBSD 2.2.8-RELEASE To: "Zaitsau, Andrei" Subject: Re: sed & awk help...?! Date: Thu, 8 Feb 2001 04:36:07 +0800 X-Mailer: KMail [version 1.0.28] Content-Type: text/plain References: <054F7DAA9E54D311AD090008C74CE9BD01F1E94E@exchange.panasonicfa.com> In-Reply-To: <054F7DAA9E54D311AD090008C74CE9BD01F1E94E@exchange.panasonicfa.com> Cc: freebsd-questions@FreeBSD.org MIME-Version: 1.0 Message-Id: <01020804390900.25931@FreeBSD.mine.nu> Content-Transfer-Encoding: 8bit Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG On Thu, 08 Feb 2001, Zaitsau, Andrei wrote: > Hello Everyone, > I have small work related problem. > Can someone help me with that? It's more UNIX question. > > Please CC me as I am not subscribed to a list. > > Here The Problem. > I have a file. And there is 3 tables in it. > > 1 12 ac > 3 4 ab > 5 6 ac > 7 8 ac > 9 1 ab > 2 13 ab > 4 5 ac > 6 7 ab > 8 9 ab > > The thing I need is to do some sorting. > I guess it could be done with 'awk' or 'sed' utilities. > > Okay program looking at the first value of the first table and compare it to > the value in the second table. If it finds a match on the second table it > outputs to other file matching value plus corresponding value from the 3rd > table (just look at it as 2nd and 3rd tables are hard linked). > > example: program is looking at value '1' in the 1st table, finds exact value > in the second table and outputs this value and corresponding letters 'ab' to > a separate file (other way to see it 2nd and 3rd table are hard linked) > second step it checks value '3' from the first table and it does not find it > in 2nd table, so it skips the record. And does not output anything > Next, 5 in first table matches 5 in 2nd table so it outputs '5 ac' in the > file (2nd and 3rd tables are hardlinked) > > I am not sure if I explaining it clearly enough, but I hope someone got the > idea. > Please help me how to do it, I loose my sleep for 3 days already... > Thanks. > > > To Unsubscribe: send mail to majordomo@FreeBSD.org > with "unsubscribe freebsd-questions" in the body of the message This might help, but using a plain sh script:- START: #!/bin/sh while read a b c ; do echo "==> line is: $a $b $c" if [ "$a" = "$b" ]; then echo " $c" fi done < /where/is/the/file/it/should/read END: cheers. -- +----------------------------------------+ | /\_____ | | / ./__ | | / __/ < I do understand.. | | / ___/ | | / / | | ^^^^^^^^^^^^^^^^^^^^^^ | | *warf* *warf* | | | +----------------------------------------+ To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message