07-19-2007
scripting: multiple values from file passing to command
one of my colleagues has this question.
he has a command, C_CMD which accepts 4 variables, $1 $2 $3 $4
he wants to load up a file with multiple rows, one row per set of variables and then iteratively execute the command based on the content of the file.
example:
at the command line you'd issue:
C_CMD A1 B1 C1 D1
C_CMD A2 B2 C2 D2
C_CMD A3 B3 C3 D3
but he wants to have FILE_C with:
A1 B1 C1 D1
A2 B2 C2 D2
A3 B3 C3 D3
and then process this in a script to iteratively invoke C_CMD similar to how you would with a single variable like this
for $file in `cat \path\FILE_D`
do
D_CMD $file
done
can you assist? I thought I saw something similar here a few days ago but now cannot find it.
Lisa
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi,
I have a situation where I have to specify a different value to an awk command, I beleive i have the gist of this done, however I am not able to get this correct. Here is what I have so far
echo $id
065859555
This value occurs in a "pipe" delimited file in postition 8. Hence I would... (1 Reply)
Discussion started by: jerardfjay
1 Replies
2. Programming
I know multiple values can be returned from a function in C like this:
char **read_file ( char * , unsigned long int * );//this is the function prototypeunsigned long int number_of_words = 0;//variable defined in main() and initialized to 0words_from_dictionary = read_file ( "dictionary.dit" ,... (2 Replies)
Discussion started by: shoaibjameel123
2 Replies
3. Shell Programming and Scripting
I have an input file with contents like:
MainFile.dat:
12247689|7896|77698080
16768900|hh78|78959390
12247689|7896|77698080
16768900|hh78|78959390
12247689|7896|77698080
16768900|hh78|78959390
12247689|7896|77698080
16768900|hh78|78959390
12247689|7896|77698080
16768900|hh78|78959390
... (4 Replies)
Discussion started by: rkrish
4 Replies
4. UNIX for Dummies Questions & Answers
Hi,
I'm trying to write a bash script that takes a file and passes each line from the file into an array with elements separated by column.
For example:
Sample file "file1.txt":
1 name1 a first
2 name2 b second
3 name3 c third
and have arrays such as:
line1 = ( "1" "name1" "a"... (3 Replies)
Discussion started by: ShiGua
3 Replies
5. Shell Programming and Scripting
how can I pass multiple values from command line arguments
example
script.sh -arg1 op1 -arg2 op1 op2 op3 (2 Replies)
Discussion started by: nsk
2 Replies
6. Shell Programming and Scripting
sqlplus -s $USER_ID@$SID/$PWD<<EOF>sql_1.txt
set feedback off
set heading off
select 114032 as c_1 from dual ;
EOF
for i in `cat sql_1.txt`
do
sh script_1.sh $i
Currently i am passing one column value to the single unix variable.
How can i pass the values from 2... (2 Replies)
Discussion started by: rafa_fed2
2 Replies
7. Shell Programming and Scripting
I have a file containing multiple values, some of them are pipe separated which are to be read as separate values and some of them are single value all are these need to store in variables.
I need to read this file which is an input to my script
Config.txt
file name, first path, second... (7 Replies)
Discussion started by: ketanraut
7 Replies
8. Shell Programming and Scripting
Hi Guys,
i have a file where data is in the below format::
data1 data2
data3 data4
data4 data6
my script written as::
#!/bin/ksh
cd $1
at now <<END
sh $2
END
Here i want to pass the values stored in the above file one by one till the end of line.
Here if i am doing it as:: (2 Replies)
Discussion started by: Atp3530
2 Replies
9. Shell Programming and Scripting
:wall: Hi,
I have an XML file with 5 tags. I need to pass values to the XML file from a shell script that will replace values in 2 of the tags. I cannot hardcode the tag values in XML and use replace command in script as the values are likely to change.
Please help !!!!!!!!!!! (2 Replies)
Discussion started by: Monalisaa
2 Replies
10. Shell Programming and Scripting
Hi All,
We have a requirement of picking nth position value by using cut command. value would be delimited by any symbols. We have to pass delimited value and postition to get the value in a string.
ex.
echo "A,B,C,D,E" |cut -d "," -f3
echo "A|B|C|D|E"|cut -d "|" -f2
Kindly frame the... (5 Replies)
Discussion started by: KK230689
5 Replies
LEARN ABOUT REDHAT
variable
variable(n) Tcl Built-In Commands variable(n)
__________________________________________________________________________________________________________________________________________________
NAME
variable - create and initialize a namespace variable
SYNOPSIS
variable ?name value...? name ?value?
_________________________________________________________________
DESCRIPTION
This command is normally used within a namespace eval command to create one or more variables within a namespace. Each variable name is
initialized with value. The value for the last variable is optional.
If a variable name does not exist, it is created. In this case, if value is specified, it is assigned to the newly created variable. If
no value is specified, the new variable is left undefined. If the variable already exists, it is set to value if value is specified or
left unchanged if no value is given. Normally, name is unqualified (does not include the names of any containing namespaces), and the
variable is created in the current namespace. If name includes any namespace qualifiers, the variable is created in the specified names-
pace. If the variable is not defined, it will be visible to the namespace which command, but not to the info exists command.
If the variable command is executed inside a Tcl procedure, it creates local variables linked to the corresponding namespace variables (and
therefore these variables are listed by info locals.) In this way the variable command resembles the global command, although the global
command only links to variables in the global namespace. If any values are given, they are used to modify the values of the associated
namespace variables. If a namespace variable does not exist, it is created and optionally initialized.
A name argument cannot reference an element within an array. Instead, name should reference the entire array, and the initialization value
should be left off. After the variable has been declared, elements within the array can be set using ordinary set or array commands.
SEE ALSO
global(n), namespace(n), upvar(n)
KEYWORDS
global, namespace, procedure, variable
Tcl 8.0 variable(n)