This is the mail archive of the mailing list for the Cygwin project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: newby stupid question - cat mutiple files to new piped output files

Ronald Landheer-Cieslak wrote on Wednesday, November 26, 2003 12:53 PM:

> On Wed, Nov 26, 2003 at 04:55:34AM -0500, c wrote:
>> Just started to get somewhere until i wanted to cat a heap of csv
>> files and then send the unique records to a new file. I thought it
>> couldnt be to hard but now my brain hurts. Can anyone help me with a
>> line of code that will do the command below '$ cat
> d:/pc1/filename.csv
>>> uniq > d:/pc1/newfilename.csv' but i want it do it repeatidly for
>> every .csv file in that directory?
> This has nothing to do with Cygwin, but hey..
> for i in /cygdrive/d/pc1/*.csv; do
> cat $i | uniq > /cygdrive/d/pc1/newfilename.csv
> done
> This will work once, because the new files won't be there
> yet. After that, the *.csv will pick up the new files as well..

Apart from that, you will overwrite the new file each time ;-)

$ for i in /cygdrive/d/pc1/*.csv; do cat $i | uniq > /cygdrive/d/pc1/$; done

Now you avoid that your new files are picked also and all new files have new names (a .new appended).

Other approaches to do something like that:
find /cygdrive/d/pc1/*.csv -exec uniq \{} \{}.new \;

refer the manuals ...


Unsubscribe info:
Problem reports:

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]