:/hello
修改替换文件内容。
查找光标所在行的第一个hello,替换为hi。
:s/hello/hi ?
查找文件中所有hello,全部替换为hi。
:%s/hello/hi
查看文件内容。
一次性将read.md文件内容全部输出到控制台。
cat read.md
可以翻页查看,下翻一页(空格),上翻一页(b)linux常用命令,退出(q)。
more somefile
可以翻页查看,下翻一页(空格),上翻一页(b),上翻一行(↑) ,下翻一行(↓),可以搜索关键字(/keyword)。
less somefile
跳到文件末尾: G
跳到文件首行: gg
退出less : q
[root@xinxin001 files]# cat read.md
15This is a doc.
14This is a doc.
13This is a doc.
12hi,ladies and gentlemen
11This is a doc.
10This is a doc.
9This is a doc.
8hi,ladies and gentlemen
7hi,ladies and gentlemen
6This is a doc.
5This is a doc.
4This is a doc.
3hi,ladies and gentlemen
2This is a doc.
1This is a doc.
查看文件尾部的3行。
tail -3 read.md
[root@xinxin001 files]# tail -3 read.md
3hi,ladies and gentlemen
2This is a doc.
1This is a doc.
显示文件内容,文件内容改变会显示出来。小f跟踪文件的唯一inode号,就算文件改名后,还是跟踪原来这个inode表示的文件。
tail -f read.md
[root@xinxin001 files]# tail -f read.md
10This is a doc.
9This is a doc.
8hi,ladies and gentlemen
7hi,ladies and gentlemen
6This is a doc.
5This is a doc.
4This is a doc.
3hi,ladies and gentlemen
2This is a doc.
1This is a doc.
显示文件内容,文件内容改变会显示出来。大F按照文件名来跟踪。
tail -F read.md
[root@xinxin001 files]# tail -F read.md
10This is a doc.
9This is a doc.
8hi,ladies and gentlemen
7hi,ladies and gentlemen
6This is a doc.
5This is a doc.
4This is a doc.
3hi,ladies and gentlemen
2This is a doc.
1This is a doc.
查看文件头部的5行。
head -5 read.md
[root@xinxin001 files]# head -5 read.md
15This is a doc.
14This is a doc.
13This is a doc.
12hi,ladies and gentlemen
11This is a doc.
上一个教程:Linux常用命令(解释)
下一个教程:linux系统小白入门基础(含常用基本命令)