简体   繁体   中英

How to use "find ... -exec ..." correctly to move all files and directories except a few?

I'm trying to move all files from a directory except some files(or directories). How I am doing:

sudo find. ! -name 'myarq.sh'! -name '.mydir'! -name '.' ! -name '..' -exec mv {} ./* .mydir

but I get:

find: missing argument for "-exec"

I am not aware of using the "-exec" probably, I do not know which syntax is correct for the above case.

In general, the error message find: missing argument for "-exec" means that you failed to properly terminate the command, either with a ; or + . Try:

find ... -exec mv {} .mydir \;

Some implementations of find will give a performance benefit by using + (fewer subshells will be spawned):

find ... -exec mv {} .mydir +

Note that the + does not need to be escaped to the shell, but the ; does.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM