rm命令删除文件时排除特定文件

摘要:
=“Test.txt”)print$0}'`#排除多个文件rm`ls*。txt | egrep v“”`rm f`ls*。日志1 |°v“”`rm f`ls*。log|egrep v“”`rm f`ls*log|egrepv“”`注意:上面使用的符号是“”,而不是单引号rm rf`ls | egrep vbb`全部删除并保留bb目录

删除文件时排除特定文件

www.python  tab.com/html/2013/linuxkaiyuan_0205/214.html

删除当前目录下所有 *.txt文件,除了test.txt

1
2
3
4
5
6
7
8
rm `ls *.txt|egrep -v test.txt`
#或者
rm `ls *.txt|awk '{if($0 != "test.txt") print $0}'`
#排除多个文件
rm `ls *.txt|egrep -v '(test.txt|fff.txt|ppp.txt)'`
rm -f `ls *.log.1|egrep -v '(access-2010-09-06.log|error-2010-09-06.log)'`
rm -f `ls *.log|egrep -v '(access-2010-09-06.log|error-2010-09-06.log)'`
rm -f `ls *.log|egrep -v '(20100906.log)'`

注意:上面所用的符号是‘`’,而不是单引号

rm -rf `ls  |egrep -v bb` 删除所有,保留bb 目录

免责声明:文章转载自《rm命令删除文件时排除特定文件》仅用于学习参考。如对内容有疑问,请及时联系本站处理。

上篇ACM模板删除页眉和首页的reference信息display:box,按比列划分,水平均分,及垂直等高下篇

宿迁高防,2C2G15M,22元/月;香港BGP,2C5G5M,25元/月 雨云优惠码:MjYwNzM=

相关文章

远程连接ubuntu的MongoDB遇到的坑

首先连接不上,先查看云服务器上的安全组是否添加了对应的端口 如果打开了,那么久查看MongoDB是否允许远程连接 # mongod.conf # for documentation of all options, see: # http://docs.mongodb.org/manual/reference/configuration-optio...

Spring中日志的使用(log4j)

我们在开发一般常见log4j这个日志文件,它的作用主要是把记录日志。使用在两种方式,一个是日志信息输出在控制台,另一种是把日志信息记录到指定的文件。如下是log4j.properties文件的基本内容: ### direct log messages to stdout ### log4j.appender.stdout=org.apache.log4j...

Nginx – access_log格式及配置

日志格式 日志内容 192.168.199.164 – jeson [14/Apr/2018:07:17:09 +0800] “GET /?feed=rss2 HTTP/1.1” 200 13883 “http://knowledge.me/” “Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11....

LoadRunner中log的使用总结

LoadRunner中log的使用总结     1、log的设置方式。   在 runtime setting中可以设置log的生成方式:   默认的log方式:   Enable logging选中,log option是Send messages only when an error occurs.   可以修改日志的方式:   Always se...

Java中的日志——Java.util.logging、log4j、commons-logging

Java中给项目程序添加log主要有三种方式,一使用JDK中的java.util.logging包,一种是log4j,一种是commons-logging。其中log4j和commons-logging都是apache软件基金会的开源项目。这三种方式的区别如下: Java.util.logging,JDK标准库中的类,是JDK 1.4 版本之后添加的日志记...

C# 生成日志文件

自定义一个生成日志文件的类 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.IO; using PrintDatas; using System.Windows.Forms; namespace Print...