Sponsored Content
Top Forums UNIX for Dummies Questions & Answers How to pass Shell script variable to awk Post 302126811 by ghostdog74 on Friday 13th of July 2007 08:37:16 AM
Old 07-13-2007
Code:
awk -v variable=$variable .....

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Pass script variable value to AWK

HI all, some more mistery about AWK, I hope you can help me out: 1) I have a normal ksh script and sometime I call awk command. I set some variables in the script and I would like to use them up within AWK as well. Unfortunately AWK seems to forget all the variable values outside of its own... (1 Reply)
Discussion started by: BearCheese
1 Replies

2. Shell Programming and Scripting

Is it possible to pass variable from awk to shell script

Hello experts, can I return a value from gawk to a shell script ? My script as follows, #Here I want the num value to shell script so that I can use later gawk ' { split($0,num,","); print num }' gawk -v no=$number '{print no}' file1 ... (3 Replies)
Discussion started by: user_prady
3 Replies

3. Shell Programming and Scripting

Is it possible to pass variable from awk to shell back

I am passing a varaible to from Shell to awk then I am doing some maniplation for that variable inside awk. I want that maniplated variable value back to shell , Is this possible .Please let me know. (12 Replies)
Discussion started by: unishiva
12 Replies

4. Shell Programming and Scripting

pass variable from awk to shell script

Hello Experts, Actually I was searching for a solution here in this forum , but didn't get what exactly I want . Is this possible to do in awk ? I am trying to do some thing like below in ksh script . Upto my knowledge I can pass shell script to awk with "-v " option. But I... (3 Replies)
Discussion started by: user_prady
3 Replies

5. Shell Programming and Scripting

How to pass a Awk variable to another script

Read parameter from a text file with one line which stored the date value like 20080831; below is the awk command I used gawk -F, "{getline RunDate;print $RunDate" text file When print $RunDate, it display 20080831 Would like to pass this variable to another script to use but not... (6 Replies)
Discussion started by: cbauw
6 Replies

6. UNIX for Dummies Questions & Answers

How to pass a variable from shell to awk

I know this topic has been dealt with previously, but the solutions I've seen don't work for me apparently. I need to pass a variable defined in the shell to one in awk: $ echo $var1 3 $ cat aaa aaa 1 bbb 2 ccc 3 ddd 4 eee 5I've tried this, without success: $ awk... (2 Replies)
Discussion started by: metaltree
2 Replies

7. Shell Programming and Scripting

Pass awk array variable to shell

Hi, all suppose I have following myfile (delimited by tab) aa bb cc dd ee ffand I have following awk command: awk 'BEGIN{FS="\t"}{AwkArrayVar_1=$1;AwkArrayVar_2=$2};END{for(i=0; i<NR; i++) print i, AwkArrayVar_1, AwkArrayVar_2,}' myfileMy question is: how can I assign the awk array... (7 Replies)
Discussion started by: littlewenwen
7 Replies

8. UNIX for Dummies Questions & Answers

Pass shell Variable to awk

Hello, May i please know how do i pass the shell variable to awk expression in the below script. It is returning null #!/bin/bash UNINUM=720922 UNINUM_DESC=`awk -F'|' -v UNINUM=$2 '/UNINUM/ {print $4}' datafile` echo $UNINUM_DESC datafile 4|First|720194|asdasdad 4|First|720735|asdasdsa... (8 Replies)
Discussion started by: Ariean
8 Replies

9. Shell Programming and Scripting

Unable to pass shell script variable to awk command in same shell script

I have a shell script (.sh) and I want to pass a parameter value to the awk command but I am getting exception, please assist. diff=$1$2.diff id=$2 new=new_$diff echo "My id is $1" echo "I want to sync for user account $id" ##awk command I am using is as below cat $diff | awk... (2 Replies)
Discussion started by: Ashunayak
2 Replies

10. Shell Programming and Scripting

How to pass variable from awk script to shell?

Hi, Please need to print the Rej variable outsite the awk script which is given below...please advised how to achieve it. #!/bin/bash echo "Enter DMU Pipe delimited File name for the Feed to be validated" read DMU_File echo "Enter Pre-DMU File name for the Feed" read Predum_file ... (3 Replies)
Discussion started by: pelethangjam
3 Replies
setenv(3C)																setenv(3C)

NAME
setenv(), unsetenv() - add, update or remove an environment variable SYNOPSIS
Parameters envname Points to a string containing the name of an environment variable to be added or altered. This should not be a NULL pointer or null string, and the string should not contain an equal character. envval Points to a string containing the value to be set for the variable envname. overwrite Indicates whether to overwrite the value of envname variable or not, if it already exists. Expected values are non-zero and zero. If the environment variable does not exist in the environment, then the value of this variable is ignored. DESCRIPTION
and functions update the environment of the calling process. If envname does not exist, the function ignores the value of overwrite and adds the variable envname to the environment with the value envval. If envname exists and overwrite is non-zero, then the variable envname is updated with the new value envval. If envname exists and overwrite is zero, then the variable is not updated, and the function is considered to have completed successfully. The function deletes the variable envname from the environment, if it exists. If the envname variable does not exist in the current envi- ronment, the environment is unchanged, and the function is considered to have completed successfully. If the application modifies environ or the pointers to which it points, the behavior of and is undefined. EXTERNAL INFLUENCES
Locale The category determines the interpretation of characters in string as single- and/or multi-byte characters. International Code Set Support Single- and multi-byte character code sets are supported. RETURN VALUE
The and functions return zero on success; otherwise they return and set to indicate the error. ERRORS
If the function fails, is set to one of the following values: Sufficient memory is not available to add a variable or its value to the environment. The envname argument is a null pointer, points to an empty string, or points to a string containing an equal character. If the function fails, is set to the following value: The envname argument is a null pointer, points to an empty string, or points to a string containing an equal character. EXAMPLES
The following code adds a new environment variable to the current environment. The following code updates the variable The following code removes the variable from the current environment. WARNINGS
The and functions manipulate the environment pointed to by environ, and can be used in conjunction with However, envp (the third argument to main) is not changed. The uses to enlarge the environment (see malloc(3C)). After the or function is called, environment variables may not be in alphabetical order. AUTHOR
and were developed by HP. SEE ALSO
exec(2), getenv(3C), malloc(3C), putenv(3C), environ(5), thread_safety(5). STANDARDS CONFORMANCE
setenv(3C)
All times are GMT -4. The time now is 12:52 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy