本文共 2572 字,大约阅读时间需要 8 分钟。
[root@linuxzgf www]# cd html [root@linuxzgf html]# ls a dede include install plus special templets data images index.php member robots.txt tags.php uploads [root@linuxzgf html]# rm -rf `ls -I index.php` [root@linuxzgf html]# ls index.php [root@linuxzgf html]# 注释: ``是TAB上面那个,不是引号 2010-1-14 index.php是要保留的文件名字,此名字可以是文件夹也可以是文件名都可以 实例二: 删除文件夹内所有文件保留部分文件 [root@linuxzgf www]# cd html [root@linuxzgf html]# ls a dede include install plus special templets data images index.php member robots.txt tags.php uploads [root@linuxzgf html]# rm -rf `ls|egrep -v '(index.php|data)'` [root@linuxzgf html]# ls data index.php [root@linuxzgf html]# ls前的` 符号是tab上面的符号 ()紧跟的是单引号 index.php|data 是要保留的文件,此处可以保留多个文件 实例三: [root@linuxzgf member]# ls ajax_feedback.php article_edit.php edit_face.php js resetpassword.php uploads_add.php ajax_loginsta.php buy_action.php edit_fullinfo.php login.php search.php uploads_edit.php album_add.php buy.php edit_space_info.php mtypes.php shops_orders.php uploads.php album_edit.php caicai.php feedback.php myfriend.php shops_point.php uploads_select.php archives_add.php check_card.php flink_main.php mypay.php shops_products.php visit-history.php archives_do.php config.php guestbook_admin.php mystow.php soft_add.php archives_edit.php content_list.php images operation.php soft_edit.php archives_sg_add.php content_sg_list.php inc paycenter space archives_sg_edit.php control.php index_do.php pm.php spaceskin.php article_add.php edit_baseinfo.php index.php reg_new.php templets [root@linuxzgf member]# 删除当前目录下所有 *.php文件,除了buy.php [root@linuxzgf member]# ls buy.php images inc js paycenter space templets [root@linuxzgf member]# 方法二: [root@linuxzgf member]# ls buy.php images inc js paycenter space templets [root@linuxzgf member]# 实例五: 排除多个文件 buy.php caicai.php login.php 方法一: [root@linuxzgf member]# ls buy.php images js paycenter templets caicai.php inc login.php space [root@linuxzgf member]# [root@linuxzgf member]# rm -rf `find *.php |egrep -v '(buy.php|caicai.php|login.php)'` [root@linuxzgf member]# ls buy.php images js paycenter templets caicai.php inc login.php space [root@linuxzgf member]#转载地址:http://cnuli.baihongyu.com/