Sponsored Content
Top Forums UNIX for Dummies Questions & Answers scripting: multiple values from file passing to command Post 302127846 by LisaS on Thursday 19th of July 2007 08:53:48 PM
Old 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

passing variable values to awk command

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

Passing multiple values from a function in C

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

Splitting a file in to multiple files and passing each individual file to a command

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

Passing values from file into array in Bash

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

Command line arguments with multiple values

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

Passing multiple column values to UNIX variable

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

Read record from the text file contain multiple separated values & assign those values to variables

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

Passing variable as a file-Scripting Help

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

Passing values to an XML file from shell script

: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

Cut command with dynamic passing of delimiter and position values

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
lassign(3tcl)						       Tcl Built-In Commands						     lassign(3tcl)

__________________________________________________________________________________________________________________________________________________

NAME
lassign - Assign list elements to variables SYNOPSIS
lassign list varName ?varName ...? _________________________________________________________________ DESCRIPTION
This command treats the value list as a list and assigns successive elements from that list to the variables given by the varName arguments in order. If there are more variable names than list elements, the remaining variables are set to the empty string. If there are more list elements than variables, a list of unassigned elements is returned. EXAMPLES
An illustration of how multiple assignment works, and what happens when there are either too few or too many elements. lassign {a b c} x y z ;# Empty return puts $x ;# Prints "a" puts $y ;# Prints "b" puts $z ;# Prints "c" lassign {d e} x y z ;# Empty return puts $x ;# Prints "d" puts $y ;# Prints "e" puts $z ;# Prints "" lassign {f g h i} x y ;# Returns "h i" puts $x ;# Prints "f" puts $y ;# Prints "g" The lassign command has other uses. It can be used to create the analogue of the "shift" command in many shell languages like this: set ::argv [lassign $::argv argumentToReadOff] SEE ALSO
lindex(3tcl), list(3tcl), lset(3tcl), set(3tcl) KEYWORDS
assign, element, list, multiple, set, variable Tcl 8.5 lassign(3tcl)
All times are GMT -4. The time now is 06:57 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy