LeetCode OJ:Tenth Line(文件第十行)
How would you print just the 10th line of a file?
For example, assume that file.txt has the following content:
Line 1
Line 2
Line 3
Line 4
Line 5
Line 6
Line 7
Line 8
Line 9
Line 10
Your script should output the tenth line, which is:
Line 10
最简单的首先就是使用管道了:
# Read from the file file.txt and output the tenth line to stdout.
tail -n+ file.txt | head -n1
先倒序显示第一行到最后一行,然后使用head 来显示第一行。
LeetCode OJ:Tenth Line(文件第十行)的更多相关文章
- [LeetCode] 195. Tenth Line 第十行
Given a text file file.txt, print just the 10th line of the file. Example: Assume that file.txt has ...
- Leetcode 195 Tenth Line
Given a text file file.txt, print just the 10th line of the file. Example: Assume that file.txt has ...
- [LeetCode] Tenth Line 第十行
How would you print just the 10th line of a file? For example, assume that file.txt has the followin ...
- [Bash]LeetCode195. 第十行 | Tenth Line
Given a text file file.txt, print just the 10th line of the file. Example: Assume that file.txt has ...
- 刷题中熟悉Shell命令之Tenth Line和Transpose File [leetcode]
首先介绍题目中要用的4个Shell命令 sed awk head tail的常用方法.(打好地基,才能建成高楼!) sed:(转自:http://www.cnblogs.com/barrychiao/ ...
- LeetCode OJ 题解
博客搬至blog.csgrandeur.com,cnblogs不再更新. 新的题解会更新在新博客:http://blog.csgrandeur.com/2014/01/15/LeetCode-OJ-S ...
- Tenth Line
How would you print just the 10th line of a file? For example, assume that file.txt has the followin ...
- 备份LeetCode OJ自己编写的代码
常泡LC的朋友知道LC是不提供代码打包下载的,不像一般的OJ,可是我不备份代码就感觉不舒服- 其实我想说的是- 我自己写了抓取个人提交代码的小工具,放在GitCafe上了- 不知道大家有没有兴趣 ht ...
- 195 Tenth Line
Given a text file file.txt, print just the 10th line of the file. Example: Assume that file.txt has ...
随机推荐
- webpack打包静态资源和动态资源
1.对于静态引用的资源: <img src = "static/modelname/imgname.png"> // 修改为下面的写法 <img src = &q ...
- string integer == equals 转
java中的数据类型,可分为两类: 1.基本数据类型,也称原始数据类型.byte,short,char,int,long,float,double,boolean 他们之间的比较,应用双等号(== ...
- KVM网络性能调优
首先,我给大家看一张图,这张图是数据包从虚拟机开始然后最后到物理网卡的过程. 我们分析下这张图,虚拟机有数据包肯定是先走虚拟机自身的那张虚拟网卡,然后发到中间的虚拟化层,再然后是传到宿主机里的内核网桥 ...
- nginx之rewrite匹配需求
现在需求如下: nginx上配有aaa.example.com的虚拟主机,现在需要将访问http://aaa.example.com/api/x.x/client/的请求转到http://bbb.ex ...
- 关于JavaScript对象中的一切(二) -- 继承
先上一张我制作的思维导图.
- Continue SQL query even on errors
trymysql --force < sample_data.sql Mysql help section says -f, --force Continue even if w ...
- Oracle邮件推送函数
CREATE OR REPLACE PROCEDURE PROCSENDEMAIL ( P_TXT VARCHAR2, P_SUB VARCHAR2, P_SENDOR VARCHAR2, P_REC ...
- erwin逆向工程,logical模型列名修改为中文
逆向工程,应该选择physical template,这样拷贝到logical/physical 模型中,才可以将logical模型的列名修改为中文.
- Android开发-网络通信2
调试了三种通信方法:HttpClient.AsyncHttpClient 和 Volley . HttpClient 测试代码[1]: public class HttpUtil { public s ...
- target 标签
<!DOCTYPE html><html><head><style>:target{border: 2px solid #D4D4D4;backgrou ...