Sponsored Content
Top Forums Shell Programming and Scripting Passing Shell variable from file to another command Post 302935479 by RavinderSingh13 on Tuesday 17th of February 2015 02:41:47 AM
Old 02-17-2015
Hello Rakesh,

Following may help you in same. Please use code tags for commands/code/Inputs you use in your posts as per forum rules.
Code:
while read var1 var2 
do 
 First_var=$var1; 
 Second_var=$var2; 
 echo "First Var: " $First_var; 
 echo "Second Var: " $Second_var; 
done < "Input_file"
 
OR
 
while read var1 var2 
do 
 echo "First Var: " $var1; 
 echo "Second Var: " $var2; 
done < "Input_file"

You can take variables and do operations as per your need in place of printing them(which I have done for an example).

Hope this helps.

Thanks,
R. Singh

Last edited by RavinderSingh13; 02-17-2015 at 03:44 AM.. Reason: Added one more solution
This User Gave Thanks to RavinderSingh13 For This Post:
 

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
Compare(3pm)						User Contributed Perl Documentation					      Compare(3pm)

NAME
Struct::Compare - Recursive diff for perl structures. SYNOPSIS
use Struct::Compare; my $is_different = compare($ref1, $ref2); DESCRIPTION
Compares two values of any type and structure and returns true if they are the same. It does a deep comparison of the structures, so a hash of a hash of a whatever will be compared correctly. This is especially useful for writing unit tests for your modules! PUBLIC FUNCTIONS
o $bool = compare($var1, $var2) Recursively compares $var1 to $var2, returning false if either structure is different than the other at any point. If both are undefined, it returns true as well, because that is considered equal. BUGS
/NEEDED ENHANCEMENTS o blessed references compare currently does not deal with blessed references. I need to look into how to deal with this. LICENSE
(The MIT License) Copyright (c) 2001 Ryan Davis, Zen Spider Software Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. AUTHOR
Ryan Davis <ryand-cmp@zenspider.com> Zen Spider Software <http://www.zenspider.com/ZSS/> perl v5.12.4 2011-07-04 Compare(3pm)
All times are GMT -4. The time now is 10:30 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy