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