你可以用find
命令的-ok
谓词来实现一些东西:
Run Code Online (Sandbox Code Playgroud)-ok command ; Like -exec but ask the user first. If the user agrees, run the command. Otherwise just return false. If the command is run, its standard input is redirected from /dev/null.
所以例如
$ find . -maxdepth 1 -mindepth 1 -name '*.jpg' -ok cp -t ../newdir {} \;
< cp ... ./aaa.jpg > ? y
< cp ... ./aaa-small.jpg > ? n
< cp ... ./bbb.jpg > ? n
< cp ... ./ccc-small.jpg > ? y
< cp ... ./ccc.jpg > ? y
< cp ... ./bbb-small.jpg > ? n
$ ls ../newdir
aaa.jpg ccc.jpg ccc-small.jpg
Run Code Online (Sandbox Code Playgroud)