Sponsored Content
Top Forums Shell Programming and Scripting Using two shell variables in single AWK statement Post 302236207 by radoulov on Monday 15th of September 2008 04:11:14 AM
Old 09-15-2008
Quote:
[...]However, i want to introduce another shell variable, named, defnfile in the statement, in place of hardcoded path for efgh.txt like:

awk -v var=$meas -F, '$1==var' $defnfile > temp1.csv

This does not work..
What's the error message that you get?

P.S. Quoting the variables is a good habit:

Code:
awk -v var="$meas" -F, '$1==var' "$defnfile" > temp1.csv

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Using shell variables In awk

Oh its not my day for syntax... cat gzipsize.txt | awk '{print "echo",$1,$2} > master.txt I have read a lot about the awk -v but haven't been able to get it to work. I have a variable in my script and I'm looking just to push it into the awk after the $2 (or anywhere would do)!!! Every... (11 Replies)
Discussion started by: nortypig
11 Replies

2. Shell Programming and Scripting

Reading Multiple Variables From a Single Line in Shell

I'm a Linux newb, I've been running a Debian Linux server for about a year now, and I've written some simple scripts to automate various things, but I still don't know much, and I forget what I learn as fast as I figure it out... Anyway, that really isn't important, I just want you to know that... (14 Replies)
Discussion started by: Drek
14 Replies

3. Shell Programming and Scripting

single quotes in awk statement

Hi, I have written a code to modify a string say, StringA=abc,def,ghi I need to change it to something like: StringB=This means abc='ABC', This mean def='DEF', This means ghi= 'GHI' StringB=$(echo $StringA | awk -F',' 'BEGIN { OFS="," } { for (i=1; i<=NF;i++) $i="This means... (2 Replies)
Discussion started by: tostay2003
2 Replies

4. Shell Programming and Scripting

AWK: replace single positional character given variables

I already have accomplished this task using sed and arrays, but since I get the variable using awk, I figured I'd ask this question and maybe I can get a cleaner solution using strictly awk.. I just can't quite grasp it in awk. Story: I'm automating the (re)configuration of network interfaces,... (3 Replies)
Discussion started by: System Shock
3 Replies

5. Shell Programming and Scripting

awk pattern match and search in single statement

Hi All, I am trying to alter all lines between EXEC SQL and END-EXEC that have an INCLUDE in them. The following code search="INCLUDE " cp -f ${WORK}/$file.in ${WORK}/$file.wrk2 for item in `echo $search `; do > ${WORK}/$file.wrk1 awk -vITEM="$item" '{ if ( $0... (3 Replies)
Discussion started by: Bruble
3 Replies

6. Shell Programming and Scripting

awk - take variables out to shell

Hi, How could we take the value of awk variables out to shell? I know the following methods 1. awk '{print $1}' < file | read a echo $a 2. a=`awk '{print $1}' < file` echo $a Please let me know if there are any other methods. Also, how do we take more than 1 variable value... (4 Replies)
Discussion started by: Thumban
4 Replies

7. UNIX for Dummies Questions & Answers

variables in awk statement

Hi, i can print 2nd, 4th and 6th columns in a file using the shell command: awk -F "|" '{print $2 $4 $6}' file1.txt Now, the position and number of columns can be variable and from a variable POSLIST So let's say POSLIST='$2 $4 $6' when i use the command: a) awk -F "|" '{print... (2 Replies)
Discussion started by: ysrini
2 Replies

8. Shell Programming and Scripting

Using Shell variables in awk

Hi All, I have a file which I am reading and looking for "EXIT" statement. I want to insert ":JCWPROD" after each EXIT statement only if ":JCWPROD" doesn't exist. Here is the sample file : EXIT Testing EXIT tesing123 EXIT Desired file : EXIT :JCWPROD Testing EXIT :JCWPROD... (7 Replies)
Discussion started by: nua7
7 Replies

9. Shell Programming and Scripting

Can we convert 3 awk statements in a single statement

Hi, Can we use 3 statements convert in a single statement. First statement output using the second statement and the second statement output using the third statement please let me know the syntax so that I can able to merge all the three statement. (2 Replies)
Discussion started by: Priti2277
2 Replies

10. Shell Programming and Scripting

Single quotes insert statement using awk

Hi, Need help, using awk command to insert statement awk -v q="'" '{ print "db2 connect to repolab > /dev/null; " "\n" "db2 -x \" select name from IBMPDQ.PROFILE where managed_database = " q $1"_"$3"__0" q "\"" } ' profile.txt | sh - | awk -v i="'" ' { print "db2 connect to repolab >... (1 Reply)
Discussion started by: Mathew_paul
1 Replies
WDDX_SERIALIZE_VARS(3)							 1						    WDDX_SERIALIZE_VARS(3)

wddx_serialize_vars - Serialize variables into a WDDX packet

SYNOPSIS
string wddx_serialize_vars (mixed $var_name, [mixed $...]) DESCRIPTION
Creates a WDDX packet with a structure that contains the serialized representation of the passed variables. PARAMETERS
This function takes a variable number of parameters. o $var_name - Can be either a string naming a variable or an array containing strings naming the variables or another array, etc. o $... - RETURN VALUES
Returns the WDDX packet, or FALSE on error. EXAMPLES
Example #1 wddx_serialize_vars(3) example <?php $a = 1; $b = 5.5; $c = array("blue", "orange", "violet"); $d = "colors"; $clvars = array("c", "d"); echo wddx_serialize_vars("a", "b", $clvars); ?> The above example will output: <wddxPacket version='1.0'><header/><data><struct><var name='a'><number>1</number></var> <var name='b'><number>5.5</number></var><var name='c'><array length='3'> <string>blue</string><string>orange</string><string>violet</string></array></var> <var name='d'><string>colors</string></var></struct></data></wddxPacket> PHP Documentation Group WDDX_SERIALIZE_VARS(3)
All times are GMT -4. The time now is 08:32 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy