Re: Regular expression quiz


Subject: Re: Regular expression quiz
From: James Zuelow (e5z8652@zuelow.net)
Date: Fri May 03 2002 - 16:48:44 AKDT


----- Original Message -----
From: "Leif Sawyer" <lsawyer@gci.com>
To: "Mike Barsalou" <mbarsalou@aidea.org>; <aklug@aklug.org>
Sent: Friday, May 03, 2002 4:18 PM
Subject: RE: Regular expression quiz

>
> Mike Barsalou ponders...
> > I have files in a directory like this:
> >
> > mike-1.2.3
> > mike-jan-1.2.3
> > mike-feb-3.4.5
> > mike-mar-1.2.3
> > mike-dec-4.5.6
> > dave
> > dave-feb-1.2.3
> >
> >
> > AND
> >
> > I have a file that contains a list of file names like this:
> >
> > mike-1.2.3
> > mike-jan-1.2.3
> > mike-dec-4.5.6
> > dave
> > dave-feb-1.2.3
> >
> >
> > I want to move only the files listed in the this file to
> > another directory.
> >
> > Here is the quiz:
> >
> > What regular expression do I use?
> >
>
You don't need a regexp if I understand the contents of myfile correctly.

           mv `awk '{ print $0 }' ORS=" " myfile` newdir/

mv - we know that one.
awk '{ print $0 }' ORS=" " myfile - this is the source for the mv command.
It prints every line ({ print $0 }) seperated by a space (Output Record
Seperator=" ") from the file myfile.
(I am assuming you have all of the files you want moved listed in myfile,
and you do not have any files you DON'T want moved in myfile.)
newdir - completes the mv command by providing the destination directory.

Poor explanation of awk. man awk will give you more details.

Cheers,

James

---------
To unsubscribe, send email to <aklug-request@aklug.org>
with 'unsubscribe' in the message body.



This archive was generated by hypermail 2a23 : Fri May 03 2002 - 16:49:15 AKDT