RHCSA重定向、VIM练习

一.实验要求

二.实验步骤

1.RHCSA

(1)新建一个文件redirect.txt,并在其中写入20210804RHCSA,保存并退出

输入命令:[root@csy ~]# vim redirect.txt

(2)将cat redirect.txt 的输出结果重定向到 redirect1.txt中

[root@csy ~]# cat redirect.txt >redirect1.txt
[root@csy ~]# cat redirect1.txt
2021 08 04 RHCSA

[root@csy ~]#

(3)将cat redirect.txt noexist.txt的标准输出重定向到redirect2.txt,标准错误输出重定向到error1.txt

[root@csy ~]# cat redirect.txt noexist.txt 1>redirect3.txt 2<&1
[root@csy ~]# cat redirect3.txt
2021 08 04 RHCSA
cat: noexist.txt: No such file or directory

[root@csy ~]#

(4)将cat redirect.txt noexisttxt的标准输出和错误输出都从定向到redirect3.txt中

[root@csy ~]# cat redirect.txt noexist.txt 1>redirect3.txt 2<&1
[root@csy ~]# cat redirect3.txt
2021 08 04 RHCSA
cat: noexist.txt: No such file or directory

[root@csy ~]#

2.VIM

(1)应用vi命令在/tmp文件夹下创建文件,文件名newfile。在newfile首行输入日期时间

[root@csy ~]# vim /tmp/newfile
[root@csy ~]# cat /tmp/newfile
2023-09-22 11:00

(2)将/etc/group文档的内容读入到newfile文档中 (在日期的下-行即第2行)

[root@csy ~]# ll /etc/group
[root@csy ~]# cat /tmp/newfile
2023-09-22 11:00

(3)查找文档中包含#号字符的行,将整行删除

[root@csy ~]# vim /tmp/newfile :g/#/d
2 files to edit

(4)开启VI的行号提示功能

[root@csy ~]# vim /tmp/newfile

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值