This is the mail archive of the
cygwin
mailing list for the Cygwin project.
Re: Awk not ouputting results via echo
- From: Eliot Moss <moss at cs dot umass dot edu>
- To: Lester Anderson <arctica1963 at gmail dot com>, cygwin at cygwin dot com
- Date: Mon, 23 Nov 2015 11:53:38 -0500
- Subject: Re: Awk not ouputting results via echo
- Authentication-results: sourceware.org; auth=none
- References: <CAE3taFC=tjki1FTfbjyt+KnEGsWmrj63FMeBjgRswRwRSKdAWQ at mail dot gmail dot com> <56532F6A dot 3020906 at cs dot umass dot edu> <CAE3taFDt50FGGCdQNnH5P84RCFt7t4j1SqyTTkVsbHf0XhVBDg at mail dot gmail dot com>
- Reply-to: moss at cs dot umass dot edu
On 11/23/2015 11:24 AM, Lester Anderson wrote:
Hi Eliot,
I can see the logic of the function, but not sure how it is
implemented from the section I have:
This has to do with bash and shells in general, and is not
specific to awk or to the cygwin Unix-like environment.
But what I meant was something like the code below. When I
run it under bash in cygwin, I get this output:
-13.8013 1.80133 26.4979 40.5021 -12.2157 0.215728
Here's the code. The use of the first echo is just to send one
line to awk, so it will run its code for that line. You can drop
the echo and | if you put BEGIN just after the open quote of the
argument to awk, and add exit(0) in the awk code after awk's print
statement.
lon_min=-12
lon_max=0
lat_min=28
lat_max=39
R_d=167
R_i=20
bindvars () {
lon_e_min=$1
lon_e_max=$2
lat_e_min=$3
lat_e_max=$4
lon_i_min=$5
lon_i_max=$6
}
bindvars $(echo | awk "{R_t=6370;
pi=3.14159;
lat_av=(($lat_max+$lat_min)/2)*(pi/180.);
lon_av=(($lon_min+$lon_max)/2);
d_lat_e=($R_d/R_t)*180./pi;
d_lon_e=($R_d/(R_t*cos(lat_av)))*180./pi;
d_lat_i=($R_i/R_t)*180./pi;
d_lon_i=($R_i/(R_t*cos(lat_av)))*180./pi;
lon_e_min=$lon_min-d_lon_e;
lon_e_max=$lon_max+d_lon_e;
lat_e_min=$lat_min-d_lat_e;
lat_e_max=$lat_max+d_lat_e;
lon_i_min=$lon_min-d_lon_i;
lon_i_max=$lon_max+d_lon_i;
lat_i_min=$lat_min-d_lat_i;
lat_i_max=$lat_max+d_lat_i;
print
lon_e_min,lon_e_max,lat_e_min,lat_e_max,lon_i_min,lon_i_max,lat_i_min,lat_i_max,lat_av*180./pi,lon_av;
}")
echo $lon_e_min $lon_e_max $lat_e_min $lat_e_max $lon_i_min $lon_i_max $lat_i_min $lat_i_max $lat_av
$lon_av
Regards -- Eliot Moss
--
Problem reports: http://cygwin.com/problems.html
FAQ: http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple