[Novalug] remove commas from .csv files
Nino Pereira
pereira at speakeasy.net
Sat Mar 6 11:39:46 EST 2010
John,
thank you, that worked wonders.
Nino
John Warren wrote:
> Use the 'inline' flag, as in:
>
> sed -i 's/,/ /g' *
>
> That will change all of the existing files so make sure you have backups
> first.
>
> -John W
>
> On Sat, Mar 6, 2010 at 11:12 AM, Nino Pereira <pereira at speakeasy.net
> <mailto:pereira at speakeasy.net>> wrote:
>
> Hi smart people,
>
> In a directory I have a slew of comma-separated files, each with two
> columns.
> In this same directory, which has nothing else, I want to make new files
> wherein the commas are replaced by spaces, and the original file name
> foo.csv becomes foo.dat.
>
> Copying from an earlier discussion on this list, I do
>
> sed -e "s/,/ /" foo.csv > foo.dat
>
> and so on, replacing foo by whatever the file names are.
>
> This works. But, being lazy, I'd want to avoid typing all these
> file names, so I try
>
> sed -e "s/,/ /" *.csv > *.dat
>
> Now I get one big file called *.dat, which is useless.
>
> What's the right way to do this? Something with if ... fi no doubt,...
>
> Thank you
>
> Nino
> _______________________________________________
> Novalug mailing list
> Novalug at calypso.tux.org <mailto:Novalug at calypso.tux.org>
> http://calypso.tux.org/mailman/listinfo/novalug
>
>
More information about the Novalug
mailing list