如何grep文件中的所有数字

时间:2019-07-03 04:53:42

标签: bash

int id= view.getId();
if(id == R.id.cbox_choclate_syrup){
    if(checked)
        tag = tag + "chocolate syrup ";
}
else if(id == R.id.cbox_sprinkles){
    if(checked)
        tag = tag + "sprinkles ";
}
else if(id == R.id.cbox_crushed_nuts){
    if(checked)
        tag = tag + "crushed nuts ";
}
else if(id == R.id.cbox_cherries){
    if(checked)
        tag = tag + "cherries ";
}
else if(id == R.id.cbox_orio_cookie_crumbles){
    if(checked)
        tag = tag + "orio cookie crumbles ";
}

测试文件包含上述值。当我使用$ cat test 1 0 2 Operator 3 $ cat test ¦ grep [0-9] 1 grep测试文件时,它仅提供grep [0-9]作为输出。如何grep测试文件中的所有数字?

1 个答案:

答案 0 :(得分:0)

仅Grep号码:

grep -x -E '[[:digit:]]+'