LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
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 03-18-2010, 06:07 PM   #1
gazz1982
LQ Newbie
 
Registered: Mar 2010
Posts: 1

Rep: Reputation: 0
Question writing text to a file


Hi,

I am using Grass GIS

I have written a script which outputs a list of numbers to a file

code snippet:
r.stats -1 fs=, input=Bones_AVE > /home/gary/AVE_monte_carlo/rstats_AVE$i.csv

so this makes acsv file with one column.
I want to run it again but rather than outputing to a new csv i want to add it to this one as the next column. For this example there will be 100 rows per column.

the 1st one will make the file

[grassGIS code]> /home/gary/AVE_monte_carlo/rstats_AVE.csv
add ',' after each value
the next one

[grassGIS code] open file /home/gary/AVE_monte_carlo/rstats_AVE.csv
add ',' after each value


and so one

My linux is very rusty can anyone help?

Thanks

Gary
 
Old 03-18-2010, 06:16 PM   #2
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
Hi, welcome to LQ!

I can't think of a method completely avoiding a temporary file given
the nature of the operation ...
Code:
command | sed 's/$/,/'| paste old_file - > old_file.tmp && mv old_file.tmp old_file
Something like that should work.


Cheers,
Tink
 
  


Reply



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
Urgent! Writing to external text file with C or C++ NewbatC Linux - Newbie 7 05-19-2009 01:42 AM
I need HELP Writing text to a FILE ravi2ray Linux - Newbie 4 10-29-2008 10:10 PM
Problem with writing in a text file in C manolakis Programming 5 12-06-2006 10:18 PM
writing text to the beginning of a file linuxmandrake Linux - Newbie 3 03-26-2006 10:55 PM
Writing to a text file vb.net mrobertson Programming 5 08-04-2005 12:37 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 02:43 PM.

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
Open Source Consulting | Domain Registration