Help answer threads with 0 replies.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 05-08-2005, 09:57 PM   #1
LQ Newbie
Registered: May 2005
Posts: 1

Rep: Reputation: 0
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,
Old 05-09-2005, 12:27 AM   #2
Jerre Cope
Registered: Oct 2003
Location: Texas (central)
Distribution: ubuntu,Slackware,knoppix
Posts: 323

Rep: Reputation: 37
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.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Bash Script zaicheke Programming 3 11-07-2004 06:32 PM
bash script how to? Lleb_KCir Programming 11 05-21-2004 07:03 PM
send automatic input to a script called by another script in bash programming jorgecab Programming 2 04-01-2004 12:20 AM
bash script - incrementing a filename in a script tslinux Programming 10 08-05-2003 11:58 PM
bash script prob: how can i tell the script that a 'dd' has finished? Frustin Linux - General 2 04-02-2003 05:34 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 04:40 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration