delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2003/11/27/04:42: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
X-Authentication-Warning: localhost.localdomain: ronald set sender to blytkerchan AT users DOT sourceforge DOT net using -f
Date: Thu, 27 Nov 2003 12:17:08 +0100
From: Ronald Landheer-Cieslak <blytkerchan AT users DOT sourceforge DOT net>
To: cygwin AT cygwin DOT com
Subject: Re: newby stupid question - cat mutiple files to new piped output files
Message-ID: <20031127111708.GA13418@linux_rln.harvest>
References: <NCEKKLNHNDLBNKAHJKLCAEAMCBAA DOT camacazi AT dodo DOT com DOT au> <NCEKKLNHNDLBNKAHJKLCIEANCBAA DOT camacazi AT dodo DOT com DOT au> <20031126115253 DOT GI10265 AT linux_rln DOT harvest> <Pine DOT GSO DOT 4 DOT 56 DOT 0311261035350 DOT 1091 AT slinky DOT cs DOT nyu DOT edu>
Mime-Version: 1.0
In-Reply-To: <Pine.GSO.4.56.0311261035350.1091@slinky.cs.nyu.edu>
User-Agent: Mutt/1.4i
X-Disclaimer: I had nothing to do with it - I swear!
X-loop: linux_rln.harvest

On Wed, Nov 26, 2003 at 10:42:58AM -0500, Igor Pechtchanski wrote:
> 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?
Ehm, no, not that one..

> Or, at the very least,
> 
> 	for i in /cygdrive/d/pc1/*.csv; do
> 	  cat $i | uniq >> /cygdrive/d/pc1/newfilename.csv
> 	done
Type-o for the missing '>' - thanks for the vigilance :)

> 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.
Tha ambiguity (and the fact that this has nothing to do with Cygwin) was why
I told him to take a look at the advanced Bash scripting guide - it's very 
informative and doesn't require you to be "advanced" before you start at the
"Bash scripting" :)

rlc

--
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