如何使用 grep、sed 或 awk 删除所有不包含字母的行?
How do you delete all lines that contain no letters from the alphabet using either grep, sed, or awk?
删除所有不包含字母的行(大写或小写)
输入:
34
76
0hjjAby68xp
H5e
895
输出:
0hjjAby68xp
H5e
使用 awk:
$ awk '/[[:alpha:]]/' file
0hjjAby68xp
H5e
使用 GNU grep:
grep '[[:alpha:]]' file
或 GNU sed:
sed '/[[:alpha:]]/!d' file
输出:
0hjjAby68xp
H5e
删除所有不包含字母的行(大写或小写)
输入:
34
76
0hjjAby68xp
H5e
895
输出:
0hjjAby68xp
H5e
使用 awk:
$ awk '/[[:alpha:]]/' file
0hjjAby68xp
H5e
使用 GNU grep:
grep '[[:alpha:]]' file
或 GNU sed:
sed '/[[:alpha:]]/!d' file
输出:
0hjjAby68xp H5e