重定向
1.新建一个文件redirect.txt,并在其中写入20210804RHCSA,保存并退出
[root@localhost redhat]# echo 20210804RHCSA > redirect.txt
[root@localhost redhat]# cat redirect.txt
20210804RHCSA
2.将cat redirect.txt 的输出结果重定向到 redirect1.txt中
[root@localhost redhat]# cat redirect.txt 1>redirect1.txt
[root@localhost redhat]# ls
pipe_data.txt redirect1.txt redirect.txt text1.txt text2.txt
[root@localhost redhat]# cat redirect1.txt
20210804RHCSA
3.将cat redirect.txt noexist.txt的标准输出重定向到redirect2.txt, 标准错误输出重定向到error1.txt
[root@localhost redhat]# cat redirect.txt noexist.txt > redirect2.txt
cat: noexist.txt: No such file or directory
[root@localhost redhat]#cat redirect.txt noexist.txt 2> error1.txt
20210804RHCSA
[root@localhost redhat]# cat error1.txt
cat: noexist.txt: No such file or directory
4.将cat redirect.txt noexist.txt的标准输出和错误输出都从定向到redirect3.txt中
[root@localhost redhat]# cat redirect.txt noexist.txt &>redirect3.txt
[root@localhost redhat]# cat redirect3.txt
20210804RHCSA
cat: noexist.txt: No such file or directory
二、Vim
1.应用vi命令在/tmp文件夹下创建文件,文件名newfile。在newfile首行输入日期时间
2.将/etc/group文档的内容读入到newfile文档中(在日期的下-行即第2行)
[root@localhost redhat]#cat /etc/group >> /tmp/newfile
[root@localhost redhat]#cat /tmp/newfile
3.查找文档中包含#号字符的行,将整行删除(本文档没得#直接粘贴,不要对自己的专业知识产生深深的怀疑,你没问题,主打随性)
:g/#/d (删除带 # )
4.开启VI的行号提示功能
:set nu (标识)