View previous topic :: View next topic |
Author |
Message |
NewbieTim n00b
Joined: 18 Apr 2002 Posts: 57
|
Posted: Sun May 19, 2002 10:27 am Post subject: Multiple moves |
|
|
hi folks,
i have the following problem. I want to "mv *.xyz *" but i can't cause the last argument has to be a directory. I also remember that there was a tool called multiple move (mmv) which can do this. Is this true ?? Where can i find this in the portage tree ?? Or is there any other way to remove suffixes ?? |
|
Back to top |
|
|
recluse n00b
Joined: 18 Apr 2002 Posts: 18
|
Posted: Sun May 19, 2002 4:01 pm Post subject: |
|
|
I don't quite understand what you want to do. Could you give a little exameple maybe? _________________ =recluse= |
|
Back to top |
|
|
NewbieTim n00b
Joined: 18 Apr 2002 Posts: 57
|
Posted: Sun May 19, 2002 4:55 pm Post subject: |
|
|
ok..following example. Lets say i have following files:
foo1.jpg.exe
foo2.jpg.exe
foo3.jpg.exe
i want to remove the ".exe" of all files so that i get the following:
foo1.jpg
foo2.jpg
foo3.jpg
Can't make it with mv... |
|
Back to top |
|
|
tomte Tux's lil' helper
Joined: 08 May 2002 Posts: 122
|
Posted: Sun May 19, 2002 6:10 pm Post subject: |
|
|
NewbieTim wrote: | ok..following example. Lets say i have following files:
foo1.jpg.exe
foo2.jpg.exe
foo3.jpg.exe
i want to remove the ".exe" of all files so that i get the following:
foo1.jpg
foo2.jpg
foo3.jpg
Can't make it with mv... |
for this particular problem:
Code: |
for i in `ls --color=none *.exe`; do mv $i `basename $i .exe`; done
|
the apostrophs enclosing the ls and basename command are backticks,
found on the same key as the tilde on us-keyboards, bash expands this by executing the enclosed command and replaces it with the result of this command, very handy in countles situations.
for basename and the for-loop see daniel robbins bash courses, there are links to them in the documents section of gentoo.org
hth,
Tom |
|
Back to top |
|
|
handsomepete Guru
Joined: 21 Apr 2002 Posts: 548 Location: Kansas City, MO
|
Posted: Sun May 19, 2002 6:32 pm Post subject: |
|
|
Well, you *could* do this:
Code: | ls *.exe | awk -F'.exe' '{print "mv "$0" "$1}' | sh |
...or you could just take that and make it take arguments and make your own mmv script... unless you're just dying to figure out a way to do it directly with mv which I don't think is possible. But I could be wrong...
Edit: Oops... someone beat me to it. Cursed refresh button! |
|
Back to top |
|
|
|