Sponsored Content
Full Discussion: Passing awk Variables
Top Forums Shell Programming and Scripting Passing awk Variables Post 59906 by Perderabo on Tuesday 4th of January 2005 01:08:50 PM
Old 01-04-2005
If you do this:
awk 'BEGIN{ print "val1=a val2=b"}' < /dev/null
you will get as output:
val1=a val2=b

That just happens to be the syntax to set val1 and val2 in the shell. So you want to feed that output into the shell for execution. That will set both variables. And it should work with lesser shells.

$ eval `awk 'BEGIN{ print "val1=a val2=b"}' < /dev/null`
$ echo $val1 $val2
a b
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Passing Variables to AWK

Does anybody have an explanation for the following: The following scripts runs fine on IRIX64 6.5 but has bugs on Solaris 8. #! /bin/sh echo run only on an SGI machine echo type in linenumber read j echo value read value awk -f rmspass2 level=$value $j'step1.mlf' When the script is... (5 Replies)
Discussion started by: AreaMan
5 Replies

2. Shell Programming and Scripting

Passing Variables to Awk

Hi I have a unix shell script with an awk statement. I would like to print some of the fields of an input file. However, I would like to print them dynamically, ie by passing the literal $1 $3 into the script to define the output. I have tried the following: variable1='$1' awk... (2 Replies)
Discussion started by: Bab00shka
2 Replies

3. Shell Programming and Scripting

Passing space seprated variables in awk

Hi, How to pass space seprated variables in awk. (HP-UX, sh shell) I have the problem like below: var="Hello" var2="Manu Batham" echo $var2 | awk -v variable=${var} '{ printf "%s %s", variable, $1}' and its output is: Hello Manu while output should be: Hello Manu Batham Please... (4 Replies)
Discussion started by: manubatham20
4 Replies

4. Shell Programming and Scripting

Passing awk variables to shell

Hi. I need to parse file and assign some values to variables, right now i do like below MYHOMEDIR=`awk '/Home/ {print $NF}' output.txt` MYSHELL=`awk '/Shell/ {print $NF}' output.txt` PRGRP=`awk '/Primary/ {print $NF}' output.txt` SECGRP=`awk '/Second/ {print $NF}' output.txt` In this... (10 Replies)
Discussion started by: urello
10 Replies

5. Shell Programming and Scripting

ksh passing to awk multiple dyanamic variables awk -v

Using ksh to call a function which has awk script embedded. It parses a long two element list file, filled with text numbers (I want column 2, beginning no sooner than line 45, that's the only known thing) . It's unknown where to start or end the data collection, dynamic variables will be used. ... (1 Reply)
Discussion started by: highnthemnts
1 Replies

6. Shell Programming and Scripting

Passing variables into AWK

I'm trying to use awk to write new entries to a hosts file if they don't exist. I need to do so depending on the type of system I have. Below is what I have, but it isn't working. awk -v myip1=$IP1 myip2=$IP2 myhost1=$HOST1 myhost2=$HOST2' BEGIN { mqhost1=0; mqhost2=0; stap1=0; stap2=0; } ... (4 Replies)
Discussion started by: Boomn4x4
4 Replies

7. Shell Programming and Scripting

PAssing variables to awk arithmetic

Hi all, I am wanting to pass variables from a file to an awk arithmetic formula. When I use the formula with the value it works well. As soon as I make these variables I get an inf (infinity) response. I can certainly echo the variables back and they look correct. My googling for answers has... (3 Replies)
Discussion started by: gafoleyo73
3 Replies

8. Shell Programming and Scripting

Passing variables to awk

Hi guys, I need to fetch data from logfile between two given dates,i got the below code from our forum.It works perfect,but i need to enter the value dynamically to awk while running. awk '/2012 Jun/{p=1}!/2012 Jul/ && prev~/2012 Jul/ && p{p=0}{prev=$0}p' file i tried the below code,but... (4 Replies)
Discussion started by: mohanalakshmi
4 Replies

9. Shell Programming and Scripting

Passing awk variables to bash variables

Trying to do so echo "111:222:333" |awk -F: '{system("export TESTO=" $2)}'But it doesn't work (2 Replies)
Discussion started by: urello
2 Replies

10. Shell Programming and Scripting

awk - passing variables in and out

Am looking to pass some Linux environment variables into AWK , can I simply use the -v option ? awk -F: -v AHOME=$HOME '{ if {rm AHOME/file.txt a=2 } }' config.txt ... (4 Replies)
Discussion started by: alldbest
4 Replies
slptool(1)						      General Commands Manual							slptool(1)

NAME
slptool - SLP command line tool SYNOPSIS
/usr/bin/slpd [-v|--version] [-s|--scope scopes] [-l|--language languagetag] [command [arguments]] DESCRIPTION
slptool is a command line tool to make SLPv2 User Agent (UA) requests. It can be used for SLP lookup/advertisement in shell scripts or as a diagnostic tool. OPTIONS
-v|--version displays version of slptool and OpenSLP. -s|--scope scopes scopes is a comma separated list of scopes applicable for the command. [-l|--language languagetag languagetag is the language tag to be used for the command. findsrvs service-type [filter] findattrs url [attrids] findsrvtypes [authority] findscopes register url [attrs] deregister url getproperty propertyname EXAMPLES
slptool register service:myserv.x://myhost.com "(attr1=val1),(attr2=val2)" slptool findsrvs service:myserv.x slptool findsrvs service:myserv.x "(attr1=val1)" slptool findattrs service:myserv.x://myhost.com slptool findattrs service:myserv.x://myhost.com attr1 slptool deregister service:myserv.x://myhost.com slptool getproperty net.slp.useScopes SEE ALSO
"OpenSLP User's Guide" NOTES
This man page was written for the Debian project by Debian Developer Ganesan Rajagopal (rganesan@debian.org). You should refer to the online html documentation in the openslp-doc package for more complete and up-to-date information. BUGS
http://sourceforge.net/tracker/?group_id=1730&atid=101730 ACKNOWLEDGEMENTS
OpenSLP is developed and maintained by The OpenSLP Project (http://www.openslp.org/). OpenSLP 1.0.1 Sep 08 2001 slptool(1)
All times are GMT -4. The time now is 03:55 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy