Sponsored Content
Top Forums Shell Programming and Scripting Passing Shell variable from file to another command Post 302935478 by rakeshtomar82 on Tuesday 17th of February 2015 02:36:13 AM
Old 02-17-2015
Passing Shell variable from file to another command

Hi all,
I have a file looks like
Code:
AAAA 111
BBBB 222
CCCC 333

need to pass variable value like var1=AAAA and var2=111
to another command for three times with next values.

stuck over here

Code:
cat file | while read line
do
export var1=`awk '{print $1}'`
echo $var1
export var2=`cat file |awk '{print $2}'`
echo $var2
--------
for i in file 
command (value of var1) (value of var2)
done
--------
done



HELP

Last edited by Don Cragun; 02-17-2015 at 03:56 AM.. Reason: Add CODE tags.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

passing value to shell variable

dear all How to passing the parameters or results to outside of the AWK program? anyone can help awk '{print $1}' file1 > $a ? (2 Replies)
Discussion started by: trynew
2 Replies

2. Shell Programming and Scripting

Passing shell variable to NAWK

I am trying to make a simple script in which i take input from shell and then forward the value to nawk (BEGIN). but when i run below mention script so it give no output. echo "Enter TRUNK GROUP:" read TGR cat /omp-data/logs/5etr/080422.APX | nawk -F"|" -v P=$TGR ' BEGIN { TG=P;... (1 Reply)
Discussion started by: wakhan
1 Replies

3. UNIX for Dummies Questions & Answers

Passing a command in a variable

I need to set up a strange system through which an arbitrary command is sent to a number of different servers (well, actually, VPS accounts). We have a command "vpass" that "passes" a command from the root level to resident VPS accounts. Suppose I wanted each VPS to do some trivial thing, like... (3 Replies)
Discussion started by: treesloth
3 Replies

4. Shell Programming and Scripting

Shell to Python variable passing

Hi, I had to create a new thread as the old thread had to much of confusion I have two files shashi.sh and py.py I want to pass a variable from shashi.sh to py.py. How do i achieve that ?. shashi.sh export X=12 echo "$("pwd")" echo "$X" exec python py.py "$(X)" py.py... (0 Replies)
Discussion started by: shashi792
0 Replies

5. UNIX for Dummies Questions & Answers

Passing a Shell Variable to awk

Hello, I have a file with 4 columns. An arbitrary example is shown below: a Tp 10 xyz b Tq 8 abc c Tp 99 pqr d Tp 44 rst e Tr 98 efg Based on the values in col 2 and col 3, I will execute another program. I have been running this:... (5 Replies)
Discussion started by: Gussifinknottle
5 Replies

6. Shell Programming and Scripting

Passing Variable Parameters (C shell)

I am trying to execute a copy command via shell script. However, on occassion, 2 or more files need to copied. How do I code for the multiple arguments? Does it matter how the files are delimited? Example: I have a script to copy files from 1 dir to another called duplicate.csh In most... (1 Reply)
Discussion started by: CKT_newbie88
1 Replies

7. Shell Programming and Scripting

Passing perl variable to shell command

Can we pass perl variable to shell commands. If yes, please give some example. (2 Replies)
Discussion started by: Anjan1
2 Replies

8. Shell Programming and Scripting

Passing a variable to kill command

I have a script that kicks off several processes in the background and stored their pids in a variable as follows: PID_DUMP_TRAN=$PID_DUMP_TRAN" "$! so I then have a list of pids If I echo $PID_DUMP_TRAN I get back a list of pids e.g. 8210 8211 8212 However I then want to kill all these... (5 Replies)
Discussion started by: sjmolloy
5 Replies

9. Shell Programming and Scripting

Passing a variable as input to another shell

I have a shell program that calls another shell program the following code works . chkTimeFormat.sh "10/9/12 17:51:19:783."|read c but when I am passing the the time in a variable like in the code below, the shell chkTimeFormat.sh is not returning proper value time="10/9/12... (9 Replies)
Discussion started by: swayam123
9 Replies

10. UNIX for Dummies Questions & Answers

Passing Shell Variable to awk

Hello All, May i please why my shell variable is not getting passed into awk script. #!/bin/bash -vx i="1EB07C50" /bin/awk -v ID="$i" '/ID/ {match($0,/ID/);print substr($0,RSTART,RLENGTH)}' /var/log/ScriptLogs/keys.13556.txt Thank you. (1 Reply)
Discussion started by: Ariean
1 Replies
DEBUG_ZVAL_DUMP(3)							 1							DEBUG_ZVAL_DUMP(3)

debug_zval_dump - Dumps a string representation of an internal zend value to output

SYNOPSIS
void debug_zval_dump (mixed $variable, [mixed $...]) DESCRIPTION
Dumps a string representation of an internal zend value to output. PARAMETERS
o $variable - The variable being evaluated. RETURN VALUES
No value is returned. EXAMPLES
Example #1 debug_zval_dump(3) example <?php $var1 = 'Hello World'; $var2 = ''; $var2 =& $var1; debug_zval_dump(&$var1); ?> The above example will output: &string(11) "Hello World" refcount(3) Note Beware the refcount The refcount value returned by this function is non-obvious in certain circumstances. For example, a developer might expect the above example to indicate a refcount of 2. The third reference is created when actually calling debug_zval_dump(3). This behavior is further compounded when a variable is not passed to debug_zval_dump(3) by reference. To illustrate, consider a slightly modified version of the above example: Example #2 <?php $var1 = 'Hello World'; $var2 = ''; $var2 =& $var1; debug_zval_dump($var1); // not passed by reference, this time ?> The above example will output: string(11) "Hello World" refcount(1) Why refcount(1)? Because a copy of $var1 is being made, when the function is called. This function becomes even more confusing when a variable with a refcount of 1 is passed (by copy/value): Example #3 <?php $var1 = 'Hello World'; debug_zval_dump($var1); ?> The above example will output: string(11) "Hello World" refcount(2) A refcount of 2, here, is extremely non-obvious. Especially considering the above examples. So what's happening? When a variable has a single reference (as did $var1 before it was used as an argument to debug_zval_dump(3)), PHP's engine opti- mizes the manner in which it is passed to a function. Internally, PHP treats $var1 like a reference (in that the refcount is increased for the scope of this function), with the caveat that if the passed reference happens to be written to, a copy is made, but only at the moment of writing. This is known as "copy on write." So, if debug_zval_dump(3) happened to write to its sole parameter (and it doesn't), then a copy would be made. Until then, the parameter remains a reference, causing the refcount to be incremented to 2 for the scope of the function call. SEE ALSO
var_dump(3), debug_backtrace(3), References Explained, References Explained (by Derick Rethans). PHP Documentation Group DEBUG_ZVAL_DUMP(3)
All times are GMT -4. The time now is 09:02 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy