Move command
Solved
Poireau007
Posted messages
85
Status
Member
-
debianhunter Posted messages 119 Registration date Status Member Last intervention -
debianhunter Posted messages 119 Registration date Status Member Last intervention -
Hello everyone!
I want to move a certain number of files using mv, but I'm stuck...
What I have:
I have lots of folders in the same directory, each containing one file named xxx.html
What I want to do:
move all the xxx.html files to the same location
----
What I've done:
for i in $(ls); do cd $i | mv * /../Users/Ordi/Desktop/Dossier/; done
But it doesn't work, I feel like the pipe is not being interpreted...
Any suggestions?
Thanks.
Configuration: Ibook ^^
I want to move a certain number of files using mv, but I'm stuck...
What I have:
I have lots of folders in the same directory, each containing one file named xxx.html
What I want to do:
move all the xxx.html files to the same location
----
What I've done:
for i in $(ls); do cd $i | mv * /../Users/Ordi/Desktop/Dossier/; done
But it doesn't work, I feel like the pipe is not being interpreted...
Any suggestions?
Thanks.
Configuration: Ibook ^^
1 answer
-
Good evening,
Look at the find command, it will be easier:
find . -iname '*html' -exec mv {} . \;
Good luck!-
-
You're welcome ;o)
find will list all the files from the current directory (.) whose name matches the regular expression *html ignoring case (if you don't want that, use name instead of iname) and then executes the command mv {} . which moves (mv) each of the find results ({}) to the current directory (.)
But reading the man page will show you the incredible possibilities of find!
-