delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2003/11/26/05:27:09

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
content-class: urn:content-classes:message
Subject: RE: newby stupid question - cat mutiple files to new piped output files
MIME-Version: 1.0
Date: Wed, 26 Nov 2003 11:26:48 +0100
Message-ID: <F0D7281DAB048B438E8F5EC4ECEFBDDC175FA3@esmail.elsag.de>
X-MimeOLE: Produced By Microsoft Exchange V6.0.6249.0
X-MS-Has-Attach:
X-MS-TNEF-Correlator:
From: =?iso-8859-1?Q?J=F6rg_Schaible?= <Joerg DOT Schaible AT Elsag-Solutions DOT com>
To: <cygwin AT cygwin DOT com>
X-MIME-Autoconverted: from quoted-printable to 8bit by delorie.com id hAQAR8TT005905

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/$1.new; 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:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019