1825882 Members
2854 Online
109689 Solutions
New Discussion

Shell Scripting

 
SOLVED
Go to solution
Jayant Butte
Occasional Contributor

Shell Scripting

I am trying to build a command which will take the values for the options from any input file.
The input file has 2 fields like say,
a b
abc xyz

The following script is not useful in this case.

for i in `cat $in_file|awk '{print $1}'`
do
command -a $i -b ?
done

Can you suggest a method to overcome this situation.

Thanks

Jayant
4 REPLIES 4
linuxfan
Honored Contributor
Solution

Re: Shell Scripting

Hi Jayant,

I am afraid i don't fully understand your question, but i'll try.

cat $in_file | while read COL1 COL2
do
command -a $COL1 -b $COL2
done

this will read two variables from the file "$in_file" and store it in $COl1 and $COL2 and for each line in the file execute the command.

Is this what you were trying to do?

-Regards
Ramesh
They think they know but don't. At least I know I don't know - Socrates
someone_4
Honored Contributor

Re: Shell Scripting

Hmm if I am not mistaking you have a command
with diffent options that and you want the out put for each options. lets do something like this. ..

echo '-a option'
command -a >> file.txt
echo '####'
echo '-b option'
command -b >> file.txt

and so on ..

Richard
someone_4
Honored Contributor

Re: Shell Scripting

in lost Ramesh
Can you give me an example of a simple command that I can run with options like you said so I can see the output?

Richard
Jayant Butte
Occasional Contributor

Re: Shell Scripting

Thanks Ramesh,
Your suggestion was helpful.


Regards

Jayant