LINUX.IE, website of the Irish Linux Users' Group
Tux rules!

   
Home
New Users
Articles
Download
Projects
Community
Vendors

  Print Version
 
Archives:


planetILUG

Recent News

News Archive


Join the
ILUG
on FaceBook


Join the
ILUG
on LinkedIn


Join the
ILUG SETI
Group



















 
 :: Mailing Lists

[ILUG] Shell substitute regexp

[ILUG] Shell substitute regexp

Padraig Brady Padraig at AnteFacto.com
Tue Jul 24 13:09:19 IST 2001


You should never use ls @ the start of a pipe IMHO.
If it's simple then just use the shell globbing (echo *.dat)
like Kenn did. If it gets more complicated then use find.
Note find does it's own globing and so won't run into problems
with overflowing command lines when you have loads of files,
like echo or ls etc. will.

What's wrong with *.* ? I was just trying to find files with
a . in them. Will this cause a problem?

BTW I thought Gavin was looking for  the general solution
of how to strip ANY suffixes from files in a directory. basename
doesn't work in this general case I think.

Padraig.

Jerry Walsh wrote:

> At 11:42 24/07/01 +0100, Kenn Humborg wrote:
> 
>> > #!/bin/sh
>> > find -maxdepth 1 -type f -name "*.*" |
>> > sed -e 's/\(.*\)\.\(.*\)/"\1\.\2" "\1"/' |
>> > xargs -r -n2 mv
>>
>> Bleargh...  basename(1), my friend, basename(1):
>>
>>    for i in *.dat ; do mv $i `basename $i .dat` ; done
> 
> Why are you using find anyway? why not just ls *.dat ?
> 
> Watch that *.* glob too,
> 
> Jerry.






More information about the ILUG mailing list
Read this without the formatting.
                                                                                                    

 

Hosted by HEAnet


Maintained by the ILUG website team. The aim of Linux.ie is to support and help commercial and private users of Linux in Ireland. You can display ILUG news in your own webpages, read backend information to find out how. Networking services kindly provided by HEAnet, server kindly donated by Dell. Linux is a trademark of Linus Torvalds, used with permission. No penguins were harmed in the production or maintenance of this highly praised website. Looking for the Indian Linux Users' Group? Try here. If you've read all this and aren't a lawyer: you should be!
RSS Version
Powered by Dell