how to extract substring and numbers only using grep/sed

后端 未结 6 801
悲哀的现实
悲哀的现实 2021-02-09 14:29

I have a text file containing both text and numbers, I want to use grep to extract only the numbers I need for example, given a file as follow:

miss rate 0.21          


        
6条回答
  •  旧巷少年郎
    2021-02-09 14:47

    I believe

    sed 's|[^0-9]*\([0-9\.]*\)|\1 |g' fiilename

    will do the trick. However every entry will be on it's own line if that is ok. I am sure there is a way for sed to produce a comma or space delimited list but I am not a super master of all things sed.

提交回复
热议问题