Latest LQ Deal: Latest LQ Deals
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 03-18-2010, 07:07 PM   #1
LQ Newbie
Registered: Mar 2010
Posts: 1

Rep: Reputation: 0
Question writing text to a file


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?


Old 03-18-2010, 07:16 PM   #2
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

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

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



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

All times are GMT -5. The time now is 06:18 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