Re: Regular expression quiz


Subject: Re: Regular expression quiz
From: James Zuelow (e5z8652@zuelow.net)
Date: Sat May 04 2002 - 08:51:17 AKDT


----- Original Message -----
From: "James Gibson" <twistedhammer@subdimension.com>
To: <aklug@aklug.org>
Sent: Saturday, May 04, 2002 4:50 AM
Subject: Re: Regular expression quiz

>
> On Fri, 3 May 2002, James Zuelow wrote:
>
> why even go to that much trouble if the filenames are all in the file:
>
> mv `cat myfile` newdir/
>
Ummm, I dunno. :) Because I have the O'Reilly sed & awk book on my desk
instead of the O'Reilly cat book.

In keeping with Mike's original question about regular expressions, my
solution is superior because you can later ADD regular expressions if you
wanted to! Yeah, that's the story.

Since the cat manpage doesn't mention replacing newlines with spaces (cat
(GNU textutils) 2.0, on Debian 3.0) I'm thinking it is a bash thing. I need
to look into how bash works. I've never printed out the man page and waded
through it. I had assumed that your example would not work, because it
would do something like this:

mv `cat myfile` newdir/

mv 1st line [newline]
    Try `mv --help' for more information.
2nd line [newline]
    bash: 2nd: command not found
3rd line [newline]
    bash: 3rd: command not found
newdir/ [newline]
    bash: newdir/: command not found

That's why I used awk, as I could change the output record seperator from a
newline to a space. Mike's original file had the filenames on different
lines, so there should be a newline between all of the file names. But `cat
myfile` automatically switches the newlines to spaces. I didn't know that.

Oh well. I have the Advanced Bash Scripting guide from the LDP. I guess
it's time to start reading up on all of this instead of just picking through
the parts I need at the moment.

Cheers,

James

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



This archive was generated by hypermail 2a23 : Sat May 04 2002 - 08:51:55 AKDT