David Z
David Z

Reputation: 7041

How to move files by user name to another directory in linux

I have a folder such like:

drwxrwsr-x+ 1 dz33 dcistat  212 Sep 22 13:34 ./
drwxrwsr-x+ 1 dz33 dcistat   46 Sep  7 13:51 ../
-rw-rw----  1 qg25 dcistat  542 Sep 15 13:55 createsamplelist.R
-rwxrwxr-x  1 dz33 dcistat 3717 Sep  7 14:15 Freedman-HuEx1.0v2-Analysis.Rnw*
drwxrws---+ 1 dz33 dcistat    0 Sep 22 13:34 Gao/
-rw-rw----  1 qg25 dcistat  530 Sep 14 17:04 .log
-rwxrwxr-x  1 dz33 dcistat  154 Sep  7 13:44 Makefile*
-rwxrwx--x  1 qg25 dcistat 1191 Sep 15 09:04 pacaroma.R*
-rw-rw----  1 qg25 dcistat 1741 Sep 14 17:23 pacaroma.Rout
-rw-rw----  1 qg25 dcistat 4426 Sep 15 16:54 pacmeap.R
-rw-rw----  1 qg25 dcistat 3230 Sep 14 17:15 .RData
-rw-rw----  1 qg25 dcistat    0 Sep 14 17:04 .txt

My question is how to move all files belong to user qg25 to the directory Gao/.

Upvotes: 0

Views: 39

Answers (2)

anon
anon

Reputation: 11

find /PATH_NAME -group qg25 -exec mv -t /NEW_PATH_NAME {} +

This should do the trick but I would test it on some dummy data.

Upvotes: 1

logix
logix

Reputation: 642

find -maxdepth 1 -user qg25 -exec mv {} Gao/ \;

Upvotes: 3

Related Questions