当前位置: 技术问答>linux和unix
sed /awk 字段截取,Help!
来源: 互联网 发布时间:2016-07-21
本文导语: 我有文件AT0010+1DAYSUNTIL0120+1DAYS 或者是:AT0010UNTIL0120+1DAYS 想把AT 和UNTIL 后的时间取出来:0010 0120 不知道有什么办法呀? | 5楼的对于AT0010+1DAYSUNTIL0120+1DAYS就不对了,用下面的 [u@H /billing/user/...
我有文件AT0010+1DAYSUNTIL0120+1DAYS
或者是:AT0010UNTIL0120+1DAYS
想把AT 和UNTIL 后的时间取出来:0010 0120
不知道有什么办法呀?
或者是:AT0010UNTIL0120+1DAYS
想把AT 和UNTIL 后的时间取出来:0010 0120
不知道有什么办法呀?
|
5楼的对于AT0010+1DAYSUNTIL0120+1DAYS就不对了,用下面的
[u@H /billing/user/test]$echo "AT0010+1DAYSUNTIL0120+1DAYS"|sed "s/+1DAYS//g"|sed "s/[^0-9]*//g"
00100120
[u@H /billing/user/test]$echo "AT0010UNTIL0120+1DAYS"|sed "s/+1DAYS//g"|sed "s/[^0-9]*//g"
00100120
[u@H /billing/user/test]$echo "AT0010+1DAYSUNTIL0120+1DAYS"|sed "s/+1DAYS//g"|sed "s/[^0-9]*//g"
00100120
[u@H /billing/user/test]$echo "AT0010UNTIL0120+1DAYS"|sed "s/+1DAYS//g"|sed "s/[^0-9]*//g"
00100120
|
sed -r 's/[^0-9]*([0-9]{1,4})+1DAYS[^0-9]*([0-9]{1,4})+1DAYS/1 2/'
|
。。上个帖子好像问过吧,awk,sed都有回答记得
grep呢?
grep -Po 'd{4}' | xargs -n2
grep呢?
grep -Po 'd{4}' | xargs -n2
|
echo "AT0010UNTIL0120+1DAYS" |sed 's/+.*//g'| sed 's/[^0-9]*//g'