Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/bash/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Bash 删除所有行,其中(长度<;=10且仅限数字)或(长度<;=8且仅限小写字母)_Bash_Sed_Grep - Fatal编程技术网

Bash 删除所有行,其中(长度<;=10且仅限数字)或(长度<;=8且仅限小写字母)

Bash 删除所有行,其中(长度<;=10且仅限数字)或(长度<;=8且仅限小写字母),bash,sed,grep,Bash,Sed,Grep,我想知道一个bash命令,该命令可以从文件中删除符合以下条件之一的所有行: -仅限数字且小于等于10个字符 -只有小写字母(a-z,没有像umlaut这样的特殊字母)且小于等于8个字符 我发现sed是实现这一点的正确工具,但我无法获得正确的语法。使用grep: grep -vE '^[[:digit]]{1,10}$|^[[:lower:]]{1,8}$' file 或sed使用相同的正则表达式: sed -E '/^[[:digit:]]{1,10}$/d;/^[[:lower:]]{1,8

我想知道一个bash命令,该命令可以从文件中删除符合以下条件之一的所有行: -仅限数字且小于等于10个字符 -只有小写字母(a-z,没有像umlaut这样的特殊字母)且小于等于8个字符

我发现sed是实现这一点的正确工具,但我无法获得正确的语法。

使用
grep

grep -vE '^[[:digit]]{1,10}$|^[[:lower:]]{1,8}$' file
sed
使用相同的正则表达式:

sed -E '/^[[:digit:]]{1,10}$/d;/^[[:lower:]]{1,8}$/d' file

到目前为止你试过什么?你看,这不是一个代码交付服务,在这里,人们放弃他们的需求,其他人做这些工作……例如,在
a-z
=
aAbBcC…z
的地区,这将失败。我通常会推荐一个character类,但如果它会受到umlaut的影响,我会在上面的命令前面加上
LC_ALL=C
,以解决时髦地区的问题。