【leetcode-shell】Tenth Line
来源:互联网 发布:实体关系图软件 编辑:程序博客网 时间:2024/06/05 16:08
随便找了一个shell脚本的题目。
打印出第十行的内容。
解法一:循环,不过效率最差,排在了最后
# Read from the file file.txt and output the tenth line to stdout.#!/bin/bashdeclare count=0cat file.txt | while read linedo if [ $count = 9 ];then echo $line exit 0 fi let count=$count+1done
解法二:sed,最快速,也最简洁
# Read from the file file.txt and output the tenth line to stdout.#!/bin/bashsed -n 10p file.txt
阅读全文
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
- Android 日历 年月选择器 下载地址:http://download.csdn.net/detail/tangjili5620/9876568
- Linux 字符设备驱动
- Twitter开源分布式自增ID算法snowflake(Java)
- 一、策略模式
- 企业架构方法综述
- 【leetcode-shell】Tenth Line
- 二维数组变一维数组,统计键值总和
- redisson整合spring
- 客户端跳转与服务器端跳转
- 微信支付接入流程——公众号支付
- Sublime Text2 插件 for ASM
- 计算基因组染色体长度的Python脚本
- 初入django2
- CentOS7上Apache impala2.7集成apache kudu1.3