|
Home > Archive > Unix Shell > August 2007 > comman line argument to awk
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
comman line argument to awk
|
|
| siddhu 2007-08-23, 1:27 pm |
| dear experts,
I am new to shell scripting and awk programming.
I am trying to write a shell script. In the shell script I am using
awk. I want to get the pattern part of awk through command line
arguments of the shell script.
lets say name of my script is gd.sh
now I run my script as
gd.sh arg
now inside the shell script one of my statement is
temp=`find . -type d | awk '{ pattern {print $0}'`
now I want pattern to be the command line argument ( i.e. arg ).
How can I achieve this?
Regards,
Siddharth
| |
| Joachim Schmitz 2007-08-23, 1:27 pm |
| "siddhu" <siddharth.sng@gmail.com> schrieb im Newsbeitrag
news:1187884137.911757.150610@z24g2000prh.googlegroups.com...
> dear experts,
>
> I am new to shell scripting and awk programming.
>
> I am trying to write a shell script. In the shell script I am using
> awk. I want to get the pattern part of awk through command line
> arguments of the shell script.
>
> lets say name of my script is gd.sh
>
> now I run my script as
>
> gd.sh arg
>
> now inside the shell script one of my statement is
>
> temp=`find . -type d | awk '{ pattern {print $0}'`
temp=`find . -type d | awk '{ '$1' {print $0}'`
Bye, Jojo
| |
|
| On 23 Aug., 18:48, siddhu <siddharth....@gmail.com> wrote:
> dear experts,
>
> I am new to shell scripting and awk programming.
>
> I am trying to write a shell script. In the shell script I am using
> awk. I want to get the pattern part of awk through command line
> arguments of the shell script.
>
> lets say name of my script is gd.sh
>
> now I run my script as
>
> gd.sh arg
>
> now inside the shell script one of my statement is
>
> temp=`find . -type d | awk '{ pattern {print $0}'`
Note that the above awk program is syntactically not correct, and
that print $0 is the default.
temp=$( find . -type d | awk -v pattern="$1" '$0 ~ pattern' )
(If you happen to have pattern meta characters in arg the result
may not be what you expect, BTW.)
Janis
>
> now I want pattern to be the command line argument ( i.e. arg ).
> How can I achieve this?
>
> Regards,
> Siddharth
|
|
|
|
|