Re: Help: How replace comma with a tab in a text file?
On Tue, Oct 24, 2000 at 05:50:23PM +0200, Vee-Eye wrote:
> >
> > I have a comma delimited ex-database file and I want to replace the commas
> > with tabs. I tried using:
> >
> > sed s/,/\tab/ filename but no go. It was a guess anyway. I tried replacing
> > the tab with a * and it worked, but only for first line of items, mleaving
> > the rest of the fields with commas.
> >
> > Any suggestions?
> >
> You could use tr for this job:
>
> tr ',' '\t' < file > newfile
just a word of caution: if your ex-database file is in CSV format
(as for example used by some M$ programs) then you might get problems,
if there are strings in your data containing commas, as in
1,"Smith, Joe",3, ...
The tr method replaces *every* comma, so it's a little too simple
for the case mentioned above.
If you are sure that this cannot happen, then just forget about this
mail...
--
Erdmut Pfeifer
science+computing gmbh
-- Bugs come in through open windows. Keep Windows shut! --
Reply to: