![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Accessing variables of one shell script in another shell script | rsendhilmani | Shell Programming and Scripting | 2 | 03-17-2009 01:17 AM |
| Accessing PL/SQL OUT variables in Korn Shell Script | bright_future | UNIX for Advanced & Expert Users | 4 | 12-02-2008 12:02 PM |
| accessing unix variables in oracle | ravi raj kumar | High Level Programming | 1 | 02-06-2008 11:05 AM |
| Accessing Variables from .conf file | wayne1411 | Shell Programming and Scripting | 7 | 01-30-2008 04:30 PM |
| accessing ksh variables from awk | trupti wagh | Shell Programming and Scripting | 1 | 02-26-2007 04:11 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Accessing Shell Variables in awk or sed
Hello,
I wonder if it is possible to pass and use variables from shell environment into sed or awk. I am trying to achieve something similar to the following using sed or awk: Code:
var=some_regular_expression grep "$var" filename # Will extract lines from filename Code:
var=some_value
awk '/$var/ {print}' filename # or: sed -n '/$var/p' filename; This doesn't work same as grep
|
|
||||
|
Quote:
Code:
var=value
awk -v X=$var 'BEGIN{print X}'
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|