[:lower:]:小写字母: ‘a b c d e f g h i j k l m n o p q r s t u v w x y z’
[:space:]:空格字符: 制表符、换行符、垂直制表符、换页符、回车符和空格键符
[:upper:]:大写字母: ‘A B C D E F G H I J K L M N O P Q R S T U V W X Y Z’
使用示例
匹配所有大写字母:grep '[:upper:]' 文件名
检测磁盘使用率:awk '{if(substr($4,length($4),length($4))=="%"){print $4} else {print $1}}' ni
去掉某html文件中的tags
源html文件如下
<b>This</b> is what <spanstyle="text-decoration: underline;">I</span> meant. Understand?
使用sed命令处理
# 如果你这样搞的话,就会有问题
$ sed's/<.*>//g' html.txt
Understand?
# 要解决上面的那个问题,就得像下面这样。# 其中的'[^>]' 指定了除了>的字符重复0次或多次。
$ sed's/<[^>]*>//g' html.txt
This is what I meant. Understand?
合并行操作
待处理文本如下:
T 119.163.122.65:37018 -> 119.163.193.242:80 [AP]
x-forwarded-for: 10.87.15.180
T 119.163.193.242:80 -> 119.163.122.65:37018 [AP]
T 119.163.122.65:36792 -> 119.163.193.242:80 [AP]
x-forwarded-for: 10.86.180.87
T 119.163.193.242:80 -> 119.163.122.65:36792 [AP]
T 119.163.122.65:44387 -> 119.163.193.242:80 [AP]
x-forwarded-for: 10.86.146.16
希望处理成如下格式:
T 119.163.122.65:37018 -> 119.163.193.242:80 [AP] x-forwarded-for: 10.87.15.180
T 119.163.193.242:80 -> 119.163.122.65:37018 [AP]
T 119.163.122.65:36792 -> 119.163.193.242:80 [AP] x-forwarded-for: 10.86.180.87
T 119.163.193.242:80 -> 119.163.122.65:36792 [AP]
T 119.163.122.65:44387 -> 119.163.193.242:80 [AP] x-forwarded-for: 10.86.146.16