Computing.Net > Forums > Unix > use variable of shell script in awk

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

use variable of shell script in awk

Reply to Message Icon

Name: T
Date: February 6, 2003 at 02:09:55 Pacific
OS: Unix
CPU/Ram: -
Comment:

Hi
i've been trying to write shell script with awk that I want
to search a substring with variable of shell script

In old one ,I wrote awk that find 'xxx' in myfile :
#!/bin/ksh
awk '/xxx/' myfile

but now I want to find a substring with my variable (but it doesn't work):
.
.
.
$var = 'xxx'
awk '/$var/'my file
.
.
.

how can I solve this problem.

Thanks,
T



Sponsored Link
Ads by Google

Response Number 1
Name: anukta_c
Date: February 6, 2003 at 04:09:09 Pacific
Reply:


awk '/'$var'/' myfile


-Anukta


0
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: use variable of shell script in awk

Shell Script & Awk www.computing.net/answers/unix/shell-script-amp-awk/4594.html

korn shell script problem (using awk ? ) www.computing.net/answers/unix/korn-shell-script-problem-using-awk-/3547.html

Shell script to extract text www.computing.net/answers/unix/shell-script-to-extract-text/3999.html