I have a folder /var/www/img has lots of image files name by date.
I want to move all images with 201108 filename to /root/a
I tried this bash but without luck
Please could someone help?HTML Code:$mv $(find . -name "201108") /root/a/;
I have a folder /var/www/img has lots of image files name by date.
I want to move all images with 201108 filename to /root/a
I tried this bash but without luck
Please could someone help?HTML Code:$mv $(find . -name "201108") /root/a/;
mv *201108* /wherever/.
Moved to Programming Talk; title changed.
Bringing old hardware back to life. About problems due to upgrading.
Please visit Quick Links -> Unanswered Posts.
Don't use this space for a list of your hardware. It only creates false hits in the search engines.
You can't use the output of find (which is multi-line) directly as command parameters. In the general case, when you have a multi-line list of things that you want to pass as multiple arguments to one single command, use "xargs". However, this is fraught with peril if you want to handle spaces in names etc... It's easier to ask find to execute a command on every file that matches:
(the difference between \+or \; in the '-exec' part is that ";" has the command execute once for each file, while "+" creates a siongle command with all the files (which works very often, given Unix conventions)Code:find /var/www/img -name "201108" -exec mv {} /root/a \+
Code:find /var/www/img -name "201108" -exec mv {} /root/a \+
------------------
I run this script but failed with error
HTML Code:find: missing argument to `-exec'
“Progress is made by lazy men looking for easier ways to do things”
— Robert A. Heinlein
Good, please mark the thread 'solved'.
Bringing old hardware back to life. About problems due to upgrading.
Please visit Quick Links -> Unanswered Posts.
Don't use this space for a list of your hardware. It only creates false hits in the search engines.
Bookmarks