sed and comma-delimited file
Thomas David Rivers
rivers at dignus.com
Tue Sep 19 11:32:25 PDT 2006
"SigmaX asdf" <fydernix at gmail.com> wrote:
> Yo;
>
> I have a series of comma-delimited text files with fourteen columns of
> data and several hundred rows. I want to use a short shell script to
> strip them of the last 9 columns, leaving the same file but with just
> five of its columns. I can do it in C++, but that seems like
> overkill. How would I go about doing it with sed or a similar
> utility?
Uh.. is there no reason the cut(1) program doesn't do this?
#!/bin/sh
cat file | cut -d',' -f1-5 > /tmp/t.$$
rm -f file
mv /tmp/t.$$ file
This doesn't preserve permissions, etc... but - it's pretty
straight-forward.
- Dave Rivers -
--
rivers at dignus.com Work: (919) 676-0847
Get your mainframe programming tools at http://www.dignus.com
More information about the freebsd-stable
mailing list