Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com X-Authentication-Warning: slinky.cs.nyu.edu: pechtcha owned process doing -bs Date: Wed, 26 Nov 2003 10:42:58 -0500 (EST) From: Igor Pechtchanski Reply-To: cygwin AT cygwin DOT com To: Ronald Landheer-Cieslak cc: cygwin AT cygwin DOT com Subject: Re: newby stupid question - cat mutiple files to new piped output files In-Reply-To: <20031126115253.GI10265@linux_rln.harvest> Message-ID: References: <20031126115253 DOT GI10265 AT linux_rln DOT harvest> Importance: Normal MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII On Wed, 26 Nov 2003, Ronald Landheer-Cieslak wrote: > 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 Umm, surely you meant cat /cygdrive/d/pc1/*.csv | sort | uniq > /cygdrive/d/pc1/newfilename.csv right? Or, at the very least, for i in /cygdrive/d/pc1/*.csv; do cat $i | uniq >> /cygdrive/d/pc1/newfilename.csv done The goals of the OP weren't very clearly stated, so he might have wanted to do for i in /cygdrive/d/pc1/*.csv; do cat $i | uniq > /cygdrive/d/pc1/new$i.csv done instead. > 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.. > > Take a look at the "Advanced Bash scripting guide" which you can find at > http://tldp.org for info on how to do this kind of thing correctly.. > > HTH > rlc HTH, Igor -- http://cs.nyu.edu/~pechtcha/ |\ _,,,---,,_ pechtcha AT cs DOT nyu DOT edu ZZZzz /,`.-'`' -. ;-;;,_ igor AT watson DOT ibm DOT com |,4- ) )-,_. ,\ ( `'-' Igor Pechtchanski, Ph.D. '---''(_/--' `-'\_) fL a.k.a JaguaR-R-R-r-r-r-.-.-. Meow! "I have since come to realize that being between your mentor and his route to the bathroom is a major career booster." -- Patrick Naughton -- 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/