shell練習題7

需求以下:code

輸入一串隨機數字,而後按千分位輸出。隨機數

例如:輸入隨機數字爲「123456789」,輸出爲123,456,789sed

參考解答以下方法

-方法1co

[root@lanquark sh]# echo "123456789" | sed '{
:start
s/\(.*[0-9]\)\([0-9]\{3\}\)/\1,\2/
t start
}'

or

echo "123456789" | sed -r '{:start;s#(.*[0-9])([0-9]{3})#\1,\2#;t start}'
相關文章
相關標籤/搜索