{"list":[{"fs_id":4176732013,"path":"\/apps\/zjhui\/bash","ctime":1389845838,"mtime":1389845838,"block_list":"[\"286dc423e71186936c39e3507d2d0cf1\"]","size":2076,"isdir":0,"ifhassubdir":0,"filenum":0}],"request_id":2785468470}有这么一串,我想利用sed将"isdir":0这里的0单独取出来。利用如下命令:sed-n's/"isdir":\(.*\)/\1/p'发现匹配出来的是:{"list":[{"fs_id":4176732013,"path":"\/apps\/zjhui\/bash","ctime":1389845838,"mtime":1389845838,"block_list":"[\"286dc423e71186936c39e3507d2d0cf1\"]","size":2076,0,"ifhassubdir":0,"filenum":0}],"request_id":2785468470}isdir没了。而我想要的是isdir后面那个0(这个数字也有可能是1)求解!
1 回答
明月笑刀无情
TA贡献1828条经验 获得超4个赞
这样也行,sed-n's/.*"isdir":\([01]\).*/\1/p'。把前后无关的一堆东西都删掉。如果不是0或者1,是个整数,就写成sed-n's/.*"isdir":\([0-9]*\).*/\1/p'。
添加回答
举报
0/150
提交
取消