LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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!

Notices


Reply
  Search this Thread
Old 05-08-2005, 10:57 PM   #1
natenate5000
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:
----------------------------------

#!/bin/bash

awk -F, '{ print $2 " " $3 }' < file.csv |
while read lat long; do
r.circle 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,
Nate
 
Old 05-09-2005, 01:27 AM   #2
Jerre Cope
Member
 
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:
Quote:
printf("%s %s",$3,$4)
will print columns 3 and 4 with no linefeed.
Quote:
printf("%s\n",$5)
will print with a line feed.
 
  


Reply


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 07:32 PM
bash script how to? Lleb_KCir Programming 11 05-21-2004 08:03 PM
send automatic input to a script called by another script in bash programming jorgecab Programming 2 04-01-2004 01:20 AM
bash script - incrementing a filename in a script tslinux Programming 10 08-06-2003 12:58 AM
bash script prob: how can i tell the script that a 'dd' has finished? Frustin Linux - General 2 04-02-2003 06:34 AM


All times are GMT -5. The time now is 12:46 AM.

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