如何用shell取得字符串中的数字?
2015-08-21 15:58
295 查看
如何用shell取得字符串中的数字?
x="84 // the number of people"
grep -Eo '[0-9]+'
echo $x|grep -o '[0-9]\+'
sed 's/[^0-9]//g' file
$ awk -F'[^0-9]+' 'NF=NF' 1
grep -oP '\d+'
tr -cs '[0-9]' '\n' file
x="84 // the number of people"
grep -Eo '[0-9]+'
echo $x|grep -o '[0-9]\+'
sed 's/[^0-9]//g' file
$ awk -F'[^0-9]+' 'NF=NF' 1
grep -oP '\d+'
tr -cs '[0-9]' '\n' file
相关文章推荐
- shell把字符串中的字母去掉,只保留数字
- shell把字符串中的字母去掉,只保留数字
- shell获取系统运行状态、软硬件信息
- 你不知道的shell用法和脚本,简单&强大
- shell正则
- shell编程题目练习
- Bash Shell
- Shell编程(运算符)
- 使用PowerShell统计服务器C盘空间
- shell编程入门
- shell中的点命令与source命令的区别
- shell中的"2>&1"是什么意思?
- bash 截取字符串
- linux中shell变量$#,$@,$0,$1,$2的含义解释
- Linux shell学习
- 开启3389常用终端命令
- 【转】linux 定时执行shell脚本
- 老男孩教育shell考试题猜数字游戏实战
- 老男孩教育shell考试题猜数字游戏实战
- linux shell trap的使用