首页 > 系统服务 > 详细

【LeetCode】关于shell的几个问题

时间:2017-02-19 23:30:26      阅读:383      评论:0      收藏:0      [点我收藏+]

195. Tenth Line

输出file.txt中的第十行

答案:

# Read from the file file.txt and output the tenth line to stdout.
#!/bin/bash
sed -n 10p file.txt

193. Valid Phone Numbers

找出file.txt中符合(xxx) xxx-xxxx or xxx-xxx-xxxx格式的电话号码

答案:

1 cat file.txt | grep -Eo ^(\([0-9]{3}\) )[0-9]{3}-[0-9]{4}$|^([0-9]{3}-){2}[0-9]{4}$

 

【LeetCode】关于shell的几个问题

原文:http://www.cnblogs.com/fcyworld/p/6417712.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!