liunx输出重定向小作业

.输入重定向:将从键盘输入Welcome to my zone.换行
YYDS然后输入EOF结束键盘输入,且重定向到init——text

[root@cfhzx ~]# more <<EOF>init_text   #先重定向再从键盘输入
> welcome to my zone
> YYDS
> EOF
[root@cfhzx ~]# more init_text  #查看输入的内容

在这里插入图片描述

  1. 管道练习:

1:将echo "This is my first time to use pipe"内容输出到屏幕上,且保存到pipe_data.txt中

[root@cfhzx ~]# echo this is my first to use pipe |tee  pipe_date.txt

在这里插入图片描述

2.2. 重定向:

a.新建一个文件redirect.txt,并在其中写入20210804RHCSA,保存并退出
b.将cat redirect.txt 的输出结果重定向到 redirect1.txt中
c.将cat redirect.txt noexist.txt的标准输出重定向到redirect2.txt, 标准错误输出重定向到error1.txt
d.将cat redirect.txt noexist.txt的标准输出和错误输出都从定向到redirect3.txt中

a:
[root@cfhzx ~]# touch redirect.txt    #创建文件
[root@cfhzx ~]# vim redirect.txt      编辑文件
b:
[root@cfhzx ~]# cat redirect.txt >redirect1.txt    #将输出结果重定向到redirect.txt
[root@cfhzx ~]# more redirect1.txt   #查看redirect1.txt文件
c:
[root@cfhzx ~]# cat redirect.txt noexist.txt >redirect2.txt # 标准输出重定向
[root@cfhzx ~]# cat redirect.txt noexist.txt 2>error.txt #标准错误输出重定向
[root@cfhzx ~]# more redirect2.txt  #查看标准输出文件
[root@cfhzx ~]# more error.txt   #查看错误输出重定向文件

在这里插入图片描述

d:
[root@cfhzx ~]# cat redirect.txt noexist.txt &>redirect3.txt
[root@cfhzx ~]# more redirect3.txt  #查看文件

在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值