linux 查看文本内容

linux中tail命令---用于查看文件内容 

最基本的是cat、more和less。 
1. 如果你只想看文件的前5行,可以使用head命令,如: 
head -5 /etc/passwd 
2. 如果你想查看文件的后10行,可以使用tail命令,如: 
tail -10 /etc/passwd 或 tail -n 10 /etc/passwd 
tail -f /var/log/messages 
参数-f使tail不停地去读最新的内容,这样有实时监视的效果 用Ctrl+c来终止! 
3. 查看文件中间一段,你可以使用sed命令,如: 
sed -n '5,10p' /etc/passwd 
这样你就可以只查看文件的第5行到第10行。

猜你喜欢

转载自blog.csdn.net/Helloguoke/article/details/74188227