regex - Find directories with names matching pattern and move them -
i have bunch of directories 001/ 002/ 003/ mixed in others have letters in names. want grab directories numeric names , move them directory.
i try this:
file */ | grep ^[0-9]*/ | xargs -i{} mv {} newdir the matching part works, ends moving newdir...
i not sure understood correctly here @ least help.
use combination of find , xargs manipulate lists of files.
find -maxdepth 1 -regex './[0-9]*' -print0 | xargs -0 -i'{}' mv "{}" "newdir/{}" using -print0 , -0 , quoting replacement symbol {} make script more robust. handle situations non-printable chars presents. says passes lines using \0 char delimiter instead of \n.
Comments
Post a Comment