Given a text file file.txt, print just the 10th line of the file.

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
Note:
1. If the file contains less than 10 lines, what should you output?
2. There's at least three different solutions. Try to explore all possibilities.
Q.describe:use bash to print the tenth line of file.txt which is provide by the question  setter.
Solution:

awk 'NR == 10' file.txt
/*
awk [-F  field-separator]  'commands'  input-file(s) 
*/
Detail describe of awk in bash,please click in:
https://www.cyberciti.biz/faq/bash-scripting-using-awk/ Comment: this is my first blog article,if there are something wrong in the article,please point out,thanks.

最新文章

  1. Ubuntu 16.04 LTS发布
  2. Vue数据绑定
  3. QLineEdit 仿QQ签名框
  4. iter迭代器的应用
  5. AngularJS 路由精分
  6. Docker配置加速器
  7. 锐捷Linux版的下载和使用(福大客户端)
  8. 安装jar包到本地仓库和远程仓库
  9. C# [WIN32] [API] Global Hook
  10. 商品详情页系统的Servlet3异步化实践
  11. Arcgis for qml - 鼠标拖拽移动
  12. chrome's developer console
  13. v$instance如何生成
  14. c++之菱形继承问题
  15. 委托、多播委托(MulticastDelegate)
  16. swift UICollectionView使用
  17. vs web项目远程发布到IIS
  18. sublime php插件
  19. java算法面试题:从类似如下的文本文件中读取出所有的姓名,并打印出重复的姓名和重复的次数,并按重复次数排序 ;读取docx 读取doc 使用poi 相关jar包提集提供下载
  20. 《手把手教你学C语言》学习笔记(3)---变量

热门文章

  1. 漫谈 JVM —— 内存模型、线程、锁
  2. C# 桌面软件开发-深入学习 [1]- AY-C#人爱学不学-aaronyang技术分享
  3. Delphi调试activex
  4. WPF 简单的绕圈进度条(无cs代码)
  5. C# Windows服务以指定用户运行
  6. Win8 Metro(C#)数字图像处理--2.59 P分位法图像二值化
  7. Redis实现Timeline
  8. C语言实现的CRC16/CCITT-FALSE校验码函数
  9. 【备忘】C#语言基础-1
  10. Delphi获得一个进程的主窗体(GetWindow(AHandle, GW_OWNER)等于0的窗体才是主窗体,并且要IsWindowVisible排除Application窗口)