Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hi
Im trying to find a directory as
find / -type d -name "Maildir"
and move the find results as per the
mv -f {}/../../ `pwd` \;
Please note that this command returns an error as “Device or resource busy”.Please advice how can I accomplish this as complete;
find / -type d -name "Maildir" -exec mv -f {}/../../ `pwd` \;

My guess may be wrong.
Seems like you would pipe output from find to another command.
"Best Practices", Event viewer, host file, perfmon, antivirus, anti-spyware, Live CD's, backups, are in my top 10

I've only seen this error "Device or resource busy" when trying to move directories across file systems. It can mean you are trying to move a directory that is being used by another user or process. It can also mean that the version of Linux or Unix won't allow moving directories across file systems.
In my experience, it's best to copy a source directory structure from one location to another destination. Then, you can remove the source directory if you wish.
The tape archive command, tar, can be used to copy all files and directories from one location to another. To copy all files and directories from under /usr/nails to /usr/fred, type:
cd /usr/nails; tar cf - .|(cd /usr/fred; tar xf - )
This command changes to the source directory and creates a tar archive. The "f" option with a dash means use standard output and the period includes the current directory in the archive. Since this command is piped, the standard output of the archive becomes the standard input of the tar extraction creating the required copy. The parenthesis groups commands before the tar extraction takes place.
Instead of tar, the copy input-output command, cpio, can also be used to copy directories:
cd /usr/nails; find . -depth -print|cpio -pd /usr/fred
The pass mode, "-p," of cpio allows a list of files piped from the standard input to be copied to the target directory, /usr/fred. Be sure to change to the source directory and then do a find.
In your case, you might consider doing something like this:
# untested script find . -type d -name "Maildir" -print|while read mydir do cd "$mydir"; tar cf - .|(cd <your destination>; tar xf - ) doneLet me know if you have any questions.

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |