File Structure:
/root/tmp/test
[root@dswing test]# ll
total 12
-rw-r--r-- 1 root root 2 Dec 12 13:41 a.txt
-rw-r--r-- 1 root root 4 Dec 12 13:42 b.txt
-rw-r--r-- 1 root root 0 Dec 12 13:43 c.txt
drwxr-xr-x 2 root root 4096 Dec 12 13:50 ks
Command:
find /root/tmp/test/ -maxdepth 1 -mindepth 1 -type f -not -name c.txt | grep -i txt$ | xargs -i cp -af {} /root/tmp/test/ks
Description:
/root/tmp/test
[root@dswing test]# ll
total 12
-rw-r--r-- 1 root root 2 Dec 12 13:41 a.txt
-rw-r--r-- 1 root root 4 Dec 12 13:42 b.txt
-rw-r--r-- 1 root root 0 Dec 12 13:43 c.txt
drwxr-xr-x 2 root root 4096 Dec 12 13:50 ks
Command:
find /root/tmp/test/ -maxdepth 1 -mindepth 1 -type f -not -name c.txt | grep -i txt$ | xargs -i cp -af {} /root/tmp/test/ks
Description:
-maxdepth 1
makes it not search recursively.
-mindepth 1
makes it not include the /root/tmp/test/ path itself into the result.
-type f means search only for file type.
-not -name c.txt means all files except c.txt
grep -i txt$ means files name ends with txt.
No comments:
Post a Comment