-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On Wed, 1 Oct 2003, Yuri de Groot wrote:
> > for i in *.txt ; do mv "$i" "${i%txt}old" ; done
>
> That's still bloody complicated compared to
> ren *.txt *.old
>
> Isn't there some way to escape the wildcards in
> mv *.txt *.old
> so that mv expands it instead of the shell?
Can you prevent the shell doing globbing? Sure, pass the asterisk escaped,
with a backslash. However, that would require mv to have code in it which
works out it needs to do globbing, and additionally the syntax isn't that
pretty really..
mv's behaviour is covered by POSIX, and POSIX says you are only allowed
target_dir or target_file as the last argument.
> For all its power, the unix CLI struggles
> to do some things as simply as command.com
> it would seem.
I don't see it that way at all. There are tools (as pointed out, rename
allows this), but it's simply a consequence of a design choice that says
the shell is the one that does globbing, not the tool being executed.
This is not always the case: scp allows you to pass literal *'s to the
remote end for remote globbing (which is quite useful), but that's still
globbing, just remotely instead of locally, and it still behaves the same
way as cp and mv.
FWIW, I suspect the larger question of _why_ they want to rename all .txt
to .old would be interesting, as the answer could very well be that it
might be better to do something else.. Eg:
NOW=`date +%Y%m%d-%H%M%S`
mkdir -p backups/$NOW
mv *.txt backups/$NOW/.
Try doing that in DOS :)
- --
David Zanetti | (__)
#include <geek/unix.h> | ( oo Mooooooo
http://hairy.geek.nz/ | /(_O ./
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: Made with pgp4pine 1.75-6
iD8DBQE/ep1JT21+qRy4P+QRAvtkAJ4sIdkLfjtDIT/LWcCK8u+yXYkBXACfZQMo
bSbU35DeXqH3iJXwKq78NLY=
=fMOO
-----END PGP SIGNATURE-----