sed extracting group of digits

前端 未结 5 1648
终归单人心
终归单人心 2021-02-18 15:18

I have tried to extract a number as given below but nothing is printed on screen:

echo \"This is an example: 65 apples\" | sed -n  \'s/.*\\([0-9]*\\) apples/\\1/         


        
5条回答
  •  北荒
    北荒 (楼主)
    2021-02-18 15:59

    echo "This is an example: 65 apples" | ssed -nR -e 's/.*?\b([0-9]*) apples/\1/p'
    

    You will however need super-sed for this to work. The -R allows perl regexp.

提交回复
热议问题