leetcode:Tenth Line 【shell】
来源:互联网 发布:golang占位符 编辑:程序博客网 时间:2024/06/06 02:06
一、问题描述
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
二、问题分析
- shell整形变量操作,参考链接
- 按行读取文件,参考链接
- while循环,参考链接
- if判断,参考链接
三、shell代码
# Read from the file file.txt and output the tenth line to stdout.declare -i count=0 #声明count为整形变量cat file.txt | while read linedolet count++; #使count加1if [ $count -eq 10 ]; thenecho $linefidone
0 0
- 【Leetcode Shell】Tenth Line
- 【leetcode~Shell】:Tenth Line
- 【leetcode~Shell】:Tenth Line
- leetcode:Tenth Line 【shell】
- 【leetcode-shell】Tenth Line
- leetcode-shell-195. Tenth Line
- LeetCode 195. Tenth Line (shell)
- leetcode-195 Tenth Line
- LeetCode 195 Tenth Line
- Leetcode: Tenth Line
- Leetcode 195. Tenth Line
- [Leetcode] 195. Tenth Line
- [Leetcode] Tenth Line的笔记
- 195. Tenth Line leetcode bash
- 8.【shell】Tenth line --Accepted code
- Tenth Line
- Tenth Line
- Tenth Line
- UWB在中国可使用频段的担心
- 2016年程序员如何提高自己的方法有哪些?
- 维护篇(5.2)-15. 外网接口性能测试 ❀ 飞塔 (Fortinet) 防火墙
- Linux 4.4.6 中断向量分析
- 页表管理
- leetcode:Tenth Line 【shell】
- jvm调优-垃圾回收算法
- async模块的异步处理
- 解决利用安卓真机调试程序时日志不显示的问题
- opencv_traincascade训练haar时Error: Insufficient memory等问题
- 页面跳转
- Android开源项目分类汇总
- java并发之Semaphore(信号量)
- Redis源码分析——SDS