Newsgroups: fj.os.linux,fj.questions.unix
Path: galaxy.trc.rwcp.or.jp!news.trc!nf2.iij.ad.jp!nr0.iij.ad.jp!news.iij.ad.jp!uunet!in4.uu.net!news-peer-east.sprintlink.net!news-peer.sprintlink.net!news.sprintlink.net!Sprint!newsfeed.internetmci.com!202.216.224.169!news.dti.ad.jp!taurus!usenet
From: manmos@stellar.co.jp (Hideo "Sir MaNMOS" Morishita)
Subject: Re: How to use shell variables in awk
X-Nntp-Posting-Host: capricorn
Content-Type: text/plain; charset=ISO-2022-JP
Message-ID: <squwwfusjbj.fsf@stellar.co.jp>
Sender: usenet@stellar.co.jp
Organization: Stellar Craft, Inc. Osaka,Japan.
X-Newsreader: Gnus v5.4.66/Emacs 19.34
References: <34C4C4C8.7914@jais.u-net.com>
Mime-Version: 1.0 (generated by tm-edit 7.92)
Date: Wed, 21 Jan 1998 01:32:32 GMT
Lines: 54
Xref: galaxy.trc.rwcp.or.jp fj.os.linux:17107 fj.questions.unix:6557
X-originally-archived-at: http://galaxy.rwcp.or.jp/text/cgi-bin/newsarticle2?ng=fj.questions.unix&nb=6557&hd=a
X-reformat-date: Mon, 18 Oct 2004 15:18:22 +0900
X-reformat-comment: Tabs were expanded into 4 column tabstops by the Galaxy's archiver. See http://katsu.watanabe.name/ancientfj/galaxy-format.html for more info.


terry tashiro <tashiro@jais.u-net.com> writes:

> $B$3$s$K$A$o(B
> 
> awk$B$NCf$G(Bshell script$B$+$iEO$7$?JQ?t$r;H$$$?$$$N$G$9$,2?$+$$$$J}K!$,$"$l(B
> $B$P$H;W$$Ej9F$7$F$$$^$9!#(B
> 
> $BNc$($P(B
> 
> 
> #!/bin/csh
> 
> set NAME="aaaa"
> 
> awk 'BEGIN { \
> i=0;         \
> }            \
> /$NAME/ {    \
> print $0;    \
> }'           \
>  input_file1
> 
> 
> $B$N$h$&$K(B$NAME$B$r(Bawk$B$NCf$GE83+$7$F$/$l$?$i!J$b$A$m$s$3$l$G$OE83+$5$l$^$;(B
> $B$s!K$$$$$N$G$9$,!#(B
> $B<B:]$K$O!p(BNAME$B$NFbMF$O$3$N(Bshell script$B$N8F$S85$N(Bshell script$B$K$F@_Dj$5$l(B
> $B$^$9!#(B

#! /bin/sh

NAME=\"aaaa\"

cat << END > awkfile
BEGIN{
NAME=$NAME
i=0
}
END

cat << 'END' >> awkfile
/NAME/ {
print $0;
}
awk -f awkfile  input_file1

$B$C$F$N$O$$$+$,$G$7$g$&!#(B
$B;d$OJQ?tDj5A$N$H$3$m$@$1JL:n$j$9$k$C$F$N$GBP1~$9$k$3$H$,B?$$$G$9!#(B

-- 
   ___     $B$o$7$O!";3?a?'$N$+$9$F!<$i$,Bg9%$-$G$N$%(B
 [[o o]]            $B$U$)$C$U$)$C$U$)(B
   'J'     $B?92<(B $B$*Be41MM(B $B#M#a#N#M#O#S(B $B1QIW!w%9%F%i%/%i%U%H(B
PGP Finger = CD EA D5 A8 AD B2 FE 7D  02 74 87 52 7C B7 39 37
