From: David Thompson on
<mostly offtopic>
On Tue, 18 Mar 2008 22:32:35 -0800, glen herrmannsfeldt
<gah(a)ugcs.caltech.edu> wrote:

> zuying(a)gmail.com wrote:

> > But the data file is of 5Gb in size so it's hard to add another comma
> > there in every occasion.
>
> awk will do it with
>
> awk '{print $0,","}' oldfile > newfile
> (the quote conventions on windows make it harder to do inline)
>
Don't need the unquoted comma; that generates a field separator (which
defaults to space, harmless here) before the comma. String
concatentation in awk is done with the null operator:
sh$ awk '{print $0 ","}'
You can avoid awk "string" literals for some cases including this one
in Windows command processor by using a variable:
CMD> awk -vco=, "{print $0 co}"

However, sed is usually available where awk is, and has no issue:
sed s/$/,/ oldfile >newfile
(Even in Unixy shells where $name is special, $/ isn't.)

Also pre-patching doubles the disc space and triples the time to
read,write,read all the data, if those are problems. Unless the
Fortran can be changed to read from stdin (typically 5, as we just
discussed) and you pipe the results into it, then you only have the
cost of pipe buffering which is reasonably small. But if you can
change the Fortran, the internal-read already discussed works.

- formerly david.thompson1 || achar(64) || worldnet.att.net
 | 
Pages: 1
Prev: Call fortran in C++ project
Next: gfortran problem