Article 5F49P trying to read external file & extract a column value to use in function within a do done loop

trying to read external file & extract a column value to use in function within a do done loop

by
TempleStone4510!
from LinuxQuestions.org on (#5F49P)
Hi,

Have an issue with some scripting:
*******************************************************
#!/bin/bash
proj=w
cd /mnt/$proj/_04Images/
cat tmp00.txt
while read line
do
grep -H aaa ..etc etc.. >> tmp01.txt
grep -H bbb ..etc etc.. >> tmp01.txt
cat tmp01.txt | tr -d '\n' | awk '{printf ("%s", $0)}'>> tmp02.txt
cat tmp02.txt | awk 'BEGIN {i=(((18000*cos(-1*(atan2(8196908-8148966,585323.3-576355.2)))+576355.2))); printf (" %s\n", i)}'>> tmp02.txt

rm -f tmp01.txt
done <tmp00.txt
*******************************************************

Script runs fine & generates a multi-column file tmp02.txt:
FileName09.tif.ccc -1 -511 48799 261 0 576355 8148966 48795 585323 8196908 579665
FileName33.tif.ccc -1 -511 48799 261 0 576355 8148966 48795 585323 8196908 579665

*******************************************************
From above, I am manually generating the last column (with the atan2 function) 579665 & adding in newline (for next do-done loop).
The 579665 value is made (above cos/atan2 function) with columns of tmp02.txt (after line: cat tmp01.txt | tr -d '\n' | awk '{printf ("%s", $0)}'>> tmp02.txt)

What I'm trying to do is replace the manual numbers with that of the file to make the 579665 value. E.G. wanting to change the script line from:

cat tmp02.txt | awk 'BEGIN {i=(((18000*cos(-1*(atan2(8196908-8148966,585323.3-576355.2)))+576355.2))); printf (" %s\n", i)}'>> tmp02.txt

to

cat tmp02.txt | awk 'BEGIN {i=(((18000*cos(-1*(atan2($11-$8,$10-$7)))+$7))); printf (" %s\n", i)}'>> tmp02.txt

But the above does not input that column (e.g. $11 should be 8196908 from file tmp02.txt), but I think is either thought of as number 11 (or 0). Have tried to do other things (e.g.
using the "cut" to extract the 8196908
cat tmp02.txt | awk 'BEGIN {i=(((18000*cos(-1*(atan2($(cut tmp02.txt -f 11)-8148966,585323.3-576355.2)))+576355.2))); printf (" %s\n", i)}'>> tmp02.txt

But it keep failing.

Any straight-forward fix?

I know my script is probably not efficient etc. But am wanting to just try and get it to worklatest?d=yIl2AUoC8zA latest?i=PU6pKtE6CNE:kmLyDqEM0T0:F7zBnMy latest?i=PU6pKtE6CNE:kmLyDqEM0T0:V_sGLiP latest?d=qj6IDK7rITs latest?i=PU6pKtE6CNE:kmLyDqEM0T0:gIN9vFwPU6pKtE6CNE
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments