[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Using stupid filenames in shell scripts



Hi folks,
I'm not sure what this is exactly but I have a rename script for this:
rename *.ext to *.abc

ls *.ext | while read file; do
	OLD="$file"
	NAME=$(basename "$file" .ext)
	NEW="$NAME.abc"
	mv $OLD $NEW
done


On Sat, 2003-05-17 at 06:03, Colin Watson wrote:
> On Sat, May 17, 2003 at 12:24:05AM +0200, David Jardine wrote:
> > On Fri, May 16, 2003 at 08:25:42AM +0100, Colin Watson wrote:
> > > On Fri, May 16, 2003 at 02:41:03AM +0200, David Jardine wrote:
> > > > Yes, of course.  I'd actually never heard of the 'y' thing in 
> > > > sed and my brain(?) had substituted 's' for it.
> > > 
> > > It might help to know that that's perl, not sed. :-)
> > 
> > 's/help/really confuse you/'
> > 
> > I think I've got it sorted out, but it leads to more 
> > questions:
> > 
> > 1: Do sed and perl each have their own implementations of, 
> >    for example, 'y///' and 's///', which, as I understand 
> >    things, are identical between sed and perl?  That would 
> >    seem a duplication of effort.
> 
> I'm not sure that's really a meaningful question. sed and perl are
> completely different languages that happen to share a little common
> syntax. Regular expressions (the left-hand sides of y/// and s///) are
> not the same between sed and perl, although superficially they look
> similar. See perlre(1) for details.
> 
> > 2: The "rename" man(1) page, which refers to the command we
> >    are talking about, is headed "Perl Programmers Reference 
> >    Guide", which seems completely wrong to me.  
> > 
> >    Perl has a "rename" function with a different syntax for 
> >    use in its scripts.  "/usr/bin/rename" is indeed a perl 
> >    script, but does that mean it "is perl"?  Even if it did 
> >    originate from Larry Wall...
> 
> /usr/bin/rename is part of the Perl distribution, as 'dpkg -S' will tell
> you.
> 
> Cheers,
> 
> -- 
> Colin Watson                                  [cjwatson@flatline.org.uk]
-- 
Kevin Mark <kmark@pipeline.com>

Attachment: signature.asc
Description: This is a digitally signed message part


Reply to: