[Leetcode] Tenth Line的笔记
来源:互联网 发布:淘宝联盟活动推广 编辑:程序博客网 时间:2024/06/05 20:55
发现leetcode上面有shell脚本和sql的题目,那么就做完他们来巩固一下学过的知识。
题目如下
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 10Your script should output the tenth line, which is:
Line 10
网上有各种各样的思路和解决办法,我先share一下我自己的方法1
- Solution1: 思路就是删除前面九个答案,然后显示最头上面的一个内容。
sed '1,9d' < file.txt| head -1
- Solution2: 就显示第十个参数
awk 'NR == 10' file.txt
- Solution3: 通过sed的n参数表示只打印需要显示的
sed -n 10p file.txt
当然还有其他的方法,循环,tail等命令都是可以的,在此记录,慢慢积累。
0 0
- [Leetcode] Tenth Line的笔记
- leetcode-195 Tenth Line
- LeetCode 195 Tenth Line
- 【Leetcode Shell】Tenth Line
- Leetcode: Tenth Line
- 【leetcode~Shell】:Tenth Line
- 【leetcode~Shell】:Tenth Line
- leetcode:Tenth Line 【shell】
- Leetcode 195. Tenth Line
- 【leetcode-shell】Tenth Line
- [Leetcode] 195. Tenth Line
- 195. Tenth Line leetcode bash
- leetcode-shell-195. Tenth Line
- LeetCode 195. Tenth Line (shell)
- Tenth Line
- Tenth Line
- Tenth Line
- Leetcode:195. Tenth Line以及管道命令pipeline
- nginx分发到备站服务器导致登录失效
- C#自动轮回调用数据库
- android悬浮窗口的实现
- Android开发中立即停止AsyncTask和Thread
- eclipse或MyEclipse修改注释
- [Leetcode] Tenth Line的笔记
- 基于Spring + Spring MVC + Mybatis 高性能web构建
- 查看Eclipse 的版本
- Eclipse中项目名出现红色感叹号解决方法
- 让自己快乐的几个小建议
- js操作 ifarm contentWindow属性
- 清空IP缓存
- 出栈顺序判断
- malloc的内存分配之 malloc(0)的内存分配情况