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 ...
随机推荐
- JSON.stringify without quotes on properties?
https://stackoverflow.com/questions/11233498/json-stringify-without-quotes-on-properties/11233515 va ...
- SDUT OJ 2607
/*http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=2607*/ 题目大意:给出一个字符串,求出里 ...
- 此博客可能不再更新,往后博文将发布在 GitHub 中
在 GitHub 上, 可以建立不同的仓库,显示分类可以更明确: 有不同分支,可以打很多次草稿: 用 markdown 语法来书写比较舒服(博客园也可以设置): 最主要的是 GitHub 装逼呀!!! ...
- windows安装git客户端
1:线上git地址 https://github.com/ 2:tortoiseGit地址 http://tortoisegit.org 3:安装步骤 操作系统:Windows XP SP3 Git客 ...
- GIT使用—创建并使用远程版本库
远程版本库 (1)创建一个裸版本库 [root@localhost tmp]# git init fluff2 Initialized empty Git repository in /tmp/flu ...
- iframe的应用量还是这么大
以前查阅资料说iframe已经过时,不建议使用,可是在先进的2018年,你去随便打开一个网站,扔都可以见到iframe的身影,这不禁要发问:iframe的应用量为什么还是这么大? HTML5不再支持使 ...
- Maven 中央仓库搭建
Maven中央仓库搭建 搭建系统:Linux Centos 7.4 x64 安装环境:JDK1.8.maven3.5.4.nexus-3.13 下载:nexus-3.13.0-01-unix.tar. ...
- Apache httpd服务部署
1. yum安装 yum install httpd yum install httpd-devel yum install httpd-manual 2. 配置 vim /etc/httpd/con ...
- 20145328 《Java程序设计》实验一实验报告
20145328 <Java程序设计>实验一实验报告 实验名称 Java开发环境的熟悉(Windows + IDEA) 实验内容 使用JDK编译.运行简单的Java程序: 使用IDEA 编 ...
- HDFS的回收站 && 安全模式
回收站机制 1). HDFS 的回收站机制由 core-site.xml 中 fs.trash.interval 属性(以分钟为单位)设置,默认是 0,表示未启用.注意:配置数值应该为1440,而配置 ...