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.
If you install Buntu 17.10 remember to download a new ISO file.
Old files might contain a bug which can damage UEFI hardware. Updating an existing installation and upgrading to 17.10 (if one has faith in upgrades in general) are safe.
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'.
If you install Buntu 17.10 remember to download a new ISO file.
Old files might contain a bug which can damage UEFI hardware. Updating an existing installation and upgrading to 17.10 (if one has faith in upgrades in general) are safe.
Bookmarks