Home > Operation and Maintenance > Linux Operation and Maintenance > [Linux] awk and posix character set

[Linux] awk and posix character set

little bottle
Release: 2019-04-17 15:45:03
forward
3096 people have browsed it

awk 是一种很棒的语言,它适合文本处理和报表生成,其语法较为常见,借鉴了某些语言的一些精华,如 C 语言等。在 linux 系统日常处理工作中,发挥很重要的作用。 它允许您创建简短的程序,这些程序读取输入文件、为数据排序、处理数据、对输入执行计算以及生成报表,还有无数其他的功能。

awk posix字符集
[:alnum:]  文字数字字符
[:alpha:]  文字字符
[:digit:]  数字字符
[:graph:]  非空字符(非空格、控制字符)
[:lower:]  小写字符
[:cntrl:]  控制字符
[:print:]  非空字符(包括空格)
[:punct:]  标点符号
[:space:]  所有空白字符(新行,空格,制表符)
[:upper:]  大写字符
[:xdigit:] 十六进制数字(0-9,a-f,A-F)

测试文本:

[root@vm-228-187 test]# cat aaa.txt 
AddddE
aaaaa
123aaa
1233
Copy after login

awk 条件判断模式{动作} , 条件操作符, ~匹配正则  

存在大写字母


[root@vm-228-187 test]# cat aaa.txt |awk  '$1~ /[[:upper:]]/{print $1}' 
AddddE
Copy after login

存在数字字符


[root@vm-228-187 test]# cat aaa.txt |awk  '$1~ /[[:digit:]]/{print $1}'     
123aaa
1233
Copy after login

 相关教程:Linux视频教程 

The above is the detailed content of [Linux] awk and posix character set. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:cnblogs.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template