我正在尝试查找仅包含一组字母的行。该文件仅包含数字和小写字母。没有空间或任何东西。
很好的例子:
39568250269955376311912572precondition005426787530581443236416842014020466976603
坏例子:
1895853531360579the3170095290529923mathematici2779805995331496368099837070an1084
最佳答案
您可以尝试以下操作吗?
awk 'gsub(/[a-z]+/,"&")==1' Input_file
说明:添加上述代码的说明,仅用于说明运行代码的目的,请使用上述代码本身。
awk ' ##Starting awk program here.
gsub(/[a-z]+/,"&")==1 ##Using gsub function of awk to substitute all small letters occurrences with same values itself.
##Then checking count of it,if it is equal to 1 then print current line.
##awk works on method of condition and action, in above condition is mentioned but NO action so by default print of current line will happen.
' Input_file ##mentioning Input_file name here, which is being passed to awk program.
关于linux - 如何使用 Bash 获取仅包含一组字母的行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58476975/