-   Linux - Newbie (
-   -   Bash Script (

natenate5000 05-08-2005 10:57 PM

Bash Script
I am trying to use a simple bash script in the program Grass GIS. The script works well, I just am trying to change the output file slightly. I have basically no experience programing (I had some help with the script), so I'd appreciate any suggestions. Here is the script so far:


awk -F, '{ print $2 " " $3 }' < file.csv |
while read lat long; do output=tenmile coordinate=$lat,$long min=15300 max=16900 -b
r.statistics base=patched cover=tenmile method=distribution | tail -1 | awk '{ print $1 }'
done > tenmile-max.dat

So basically this script reads in a bunch of latitudes and longitudes and then passes them into two functions for Grass GIS. This part of the script is functioning as I want. Then it prints out the first column using awk.

What I want to change is to do a second very similar function and print data on the same line as the first piece of information. I am going to just do another r.statistics and retrieve the head instead of the tail from the data. When I place this function in the next line of the script, the resulting file has the piece of data on a second line.

It seems that print writes the data and then moves to a newline. So is there a way to not have it make a newline? Or a way to backspace to the previous line. Or some other way it could work? Then I could just write a space or comma to make a good file to put in a spreadsheet.

Thanks for any suggestions,

Jerre Cope 05-09-2005 01:27 AM

you will want to use printf rather than print. If you have a C programming reference book handy, you can lookup all the formattting possibilites. For a quick start, here's some examples:

printf("%s %s",$3,$4)
will print columns 3 and 4 with no linefeed.

will print with a line feed.

All times are GMT -5. The time now is 09:11 AM.