提示:Linux系统下,查看.csv文件的前几行或后几行的方法总结
1、head,tail 用起来
1) 单纯查看文件的***前10行或后5行***
查看 /etc/profile文件的前10行内容: head -n 10 /etc/profile
查看 /etc/profile文件的后5行内容: tail -n 5 /etc/profile
2) 查看文件的第3000~3999行
cat /etc/profile | tail -n 3000 | head -n 1000
3) 同时查看文件的***前10行和后5行***
通过***输出信息重定向***到同一个文件的方法,查看文件即可。如将内容输出到/home/test文件中:
head -n 10 /etc/profile >> /home/test
tail -n 5 /etc/profile >> /home/test
查看的话只需要打开test文件即可: cat /home/test
2、sed命令
只查看文件的第5行到第10行,sed命令:
sed -n ‘5,10p’ /etc/profile
参考文献
https://www.cnblogs.com/shoshana-kong/p/11106526.html