leetcode-195 Tenth Line
来源:互联网 发布:阿里云邮箱怎么登陆 编辑:程序博客网 时间:2024/05/16 11:35
打印一个文件中的第10行,需要注意的是如果没有10行的话,则什么也不打印
所以可以有下面几种方法:
方法一:
awk 'NR==10' file.txt //awk的默认动作就是打印$0,所以NR==10后面可以不用加{print $0}
方法二:
sed -n '10p' file.txt //如果不够10行,则什么也不打印
方法三:
line=$(cat file.txt | wc -l) //千万注意,等号前后一定不要有空格
if [ "$line" -ge 10 ] ; then //$line的双引号也可以不用加
cat file.txt | head -n 10 | tail -n 1
fi
0 0
- 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] Tenth Line的笔记
- 195. Tenth Line leetcode bash
- leetcode-shell-195. Tenth Line
- LeetCode 195. Tenth Line (shell)
- Tenth Line
- Tenth Line
- Tenth Line
- 23种设计模式...
- protobuf-c学习小结
- linux opencv 2.4
- LeetCode 55/45 Jump Game I/II-----Greedy**
- LUA5.2中文函数名支持
- leetcode-195 Tenth Line
- Linux常用软件
- 奉献一个实用的JS动画弹出层效果
- MySQL主从复制与读写分离
- 3D MAX 2015中文帮助 下载
- 找点
- centos 7核心版优化
- ORACLE_基础十九(Backup Recovery)
- 安卓刷机命令