Operating System - HP-UX
1850103 Members
1728 Online
104050 Solutions
New Discussion

Re: Differences...advantages mv vs. find

 
Richard Briggs
Regular Advisor

Differences...advantages mv vs. find

I'm moving a lot of data/subdirs from one place to another: There's a little discussion here and I'd like your $0.02

is there any difference and/or advantage when moving all the contents of a directory to another directory using either:

mv * /newdir

versus

find . -xdev | cpio -pdmuvx /newdir


Thanks


PS: If you have a different/better/favorite way ... chime in.

Richard
#find / -name coffee | cup < cream
7 REPLIES 7
Volker Borowski
Honored Contributor

Re: Differences...advantages mv vs. find

Hello,

if /newdir belongs to the same filesystem, mv just changes the inodes, no physical move happens while cpio actually reads and writes data.

If it is on diffrent filesystems, i see no real difference in the result.

Volker
Bill McNAMARA_1
Honored Contributor

Re: Differences...advantages mv vs. find

hmmmm in terms of command line I prefer the mv!

Did you actually measure with time which one is best.. in terms of performance.

Later,
Bill
It works for me (tm)
Richard Briggs
Regular Advisor

Re: Differences...advantages mv vs. find

Bill...

Both took a long time... so I can't say that there was any measurable difference....except to say that after the find command was done... I had to go back and rm the copied data. That took longer, considering the mv command (once completed) "deletes" the "copied" files.
#find / -name coffee | cup < cream
Volker Borowski
Honored Contributor

Re: Differences...advantages mv vs. find

Richard,

Do you have to do this action frequently ?
I would go for seperate filesystems in this case:

umount /last_weeks
newfs "last_week_rlvol"

umount /this_week
mount "last_week_lvol" on /this_week
mount "this_week_lvol" on /last_week

with this, you could quickly toggle two filesystems.

Volker
Richard Briggs
Regular Advisor

Re: Differences...advantages mv vs. find

No.. this was a one time thing...I had a huge filesystem of MIB data growing beyond the limits of my vg00 pv's so I decided just to break out the underlying mib data to a new lvol on vg01... to do that, I had to create the new lvol and then mv/cp/find... all the data and get it over to the new lvol. That's all. However, your tip is noted, and will come in handy... thanks!
#find / -name coffee | cup < cream
Rodney Hills
Honored Contributor

Re: Differences...advantages mv vs. find

if "mv * /newdir" is only moving files you are ok.

if it includes subdirectories and you are crossing file systems, I don't think "mv" will allow it.

If I have the room, I opt to copy rather than move, just in case something goes wrong part way through the process.
There be dragons...
Richard Briggs
Regular Advisor

Re: Differences...advantages mv vs. find

Well... I've done it both ways now.. and both work (from say /opt/dir [in lvolX in vg00] to /opt/dir2 [in lvolY in vg01 ] and actually... the first time I did the mv it did encounter an error, and the command exited...apparently, when mv encounters an error it doesn't delete the original data. For some reason, though, the find command makes me feel warmer and fuzzier. ;-)
#find / -name coffee | cup < cream