Hi,
I have a file generated like this -
- Fire SQL and store the formatted output in a temp file
echo "select path, empid, age from emp_tbl" | /usr/sql emp_db 2 > count_file | grep vol > tempFile
- The tempFile looks like this after the above statement
/vol/emp1 0732 25
/vol/emp2 0745 26
My requirement is to read each "column" of this temp file ? How can I do that ?
Thx a lot in advance. Kindly help.
Hi,
I am a totally newbie to Solaris. So, can you tell me how do use this inside a script. I ran this from the shell directly, but it does not work.
Something like this:
while read column1 column2 column3
do
# do something with $column1
# do something with $column2
# do something with $column3
.
.
done < tempFile
Jairaj
5
Try this :
awk '{print $2}' tempFile
Hi Jai,
That was great. It worked. Can you explain this commaned too :o ?
Jairaj
7
$2 - Indicates print the second field of tempFile. Space is default delimiter.
Hi Jai,
Now this has to be put in a while loop and output of the awk has to be captured in a variable for each line. How do i do that ?
Jairaj
9
I hope below is your requirement, If not pls let me know.
while read le
do
echo $le > file1.txt
var=`awk '{print $2}' file1.txt`
echo "Second value is : $var"
done < tempFile
Hi Jai,
Will keep you posted ! I am trying out the script. Thanks for the kind help.