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(文件第十行)的更多相关文章

  1. [LeetCode] 195. Tenth Line 第十行

    Given a text file file.txt, print just the 10th line of the file. Example: Assume that file.txt has ...

  2. Leetcode 195 Tenth Line

    Given a text file file.txt, print just the 10th line of the file. Example: Assume that file.txt has ...

  3. [LeetCode] Tenth Line 第十行

    How would you print just the 10th line of a file? For example, assume that file.txt has the followin ...

  4. [Bash]LeetCode195. 第十行 | Tenth Line

    Given a text file file.txt, print just the 10th line of the file. Example: Assume that file.txt has ...

  5. 刷题中熟悉Shell命令之Tenth Line和Transpose File [leetcode]

    首先介绍题目中要用的4个Shell命令 sed awk head tail的常用方法.(打好地基,才能建成高楼!) sed:(转自:http://www.cnblogs.com/barrychiao/ ...

  6. LeetCode OJ 题解

    博客搬至blog.csgrandeur.com,cnblogs不再更新. 新的题解会更新在新博客:http://blog.csgrandeur.com/2014/01/15/LeetCode-OJ-S ...

  7. Tenth Line

    How would you print just the 10th line of a file? For example, assume that file.txt has the followin ...

  8. 备份LeetCode OJ自己编写的代码

    常泡LC的朋友知道LC是不提供代码打包下载的,不像一般的OJ,可是我不备份代码就感觉不舒服- 其实我想说的是- 我自己写了抓取个人提交代码的小工具,放在GitCafe上了- 不知道大家有没有兴趣 ht ...

  9. 195 Tenth Line

    Given a text file file.txt, print just the 10th line of the file. Example: Assume that file.txt has ...

随机推荐

  1. kerberos master-slave搭建

    1. 安装kerberos server yum install krb5-server krb5-libs krb5-auth-dialog client yum install krb5-work ...

  2. elasticsearch搜索集群基础架构

    1.  elasticsearch cluster搭建 http://www.cnblogs.com/kisf/p/7326980.html   为了配套spring boot,elasticsear ...

  3. 配置linux使用mail发送邮件到163邮箱

    1.进行配置 yum install -y mailx /etc/mail.rc添加对163的授权: ##########config 163 mail############set from=jso ...

  4. ubuntu下wget的配置文件在哪里

    答:/etc/wgetrc 这个文件里可以指定代理,如: http_proxy = http://myproxy.com:8080

  5. POJ_2182 Lost Cows(线段树的简单应用)

    基本思路就是,从后往前读取数字small[i].在剩余编号集合里(一开始剩余编号集合为全集)查找第small[i]+1个编号,该编号就是对应位置牛的编号. 若直接用数组来做,则每次查找都需要遍历前n个 ...

  6. Centos7.5静默安装Oracle18c

    环境: CentOS7.5.Oracle18c(LINUX.X64_180000_db_home.zip) 1. 安装必要的依赖包 [root@bogon ~]# yum install bc bin ...

  7. Windows窗体应用程序常用的几个类的属性、方法以及事件

    System.Diagnostics.Process 属性 public bool EnableRaisingEvents { get; set; }//获取或设置在进程终止时是否应激发 Exited ...

  8. Pandas学习1

    pandas有两种自己独有的基本数据结构Series和DataFrame Series 数据结构 data 100 300 500 index 0 1 2 或者 index data 0 100 1 ...

  9. java自带的MD5

    前言:        MD5可生成16.32.64位数的签名. // MD5加码,32位 public static String toMD5(String plainText) { String r ...

  10. 做文件上传下载时报这个错com.alibaba.fastjson.JSONException: illegal identifier : \

    ::-exec-] DEBUG c.i.e.m.I.insertDataEmebeding - <== Updates: ::-exec-] ERROR c.i.e.c.CaseArchiveC ...