Linux IO和管道练习题

Linux IO和管道练习题,第1张

概述把/etc/fstab?件内容重定向到/tmp?录下?件名为fstab.out cat /etc/fstab > /tmp/fstab.out 把hello world追加到/tmp/fstab.out?件尾部 echo "hello world" >>/tmp/fstab.out 禁?覆盖重定向和强制重定向 set -Cecho "hello magedu" >/tmp/fstab.out- 把/etc/fstab?件内容重定向到/tmp?录下?件名为fstab.out

cat /etc/fstab > /tmp/fstab.out

把hello world追加到/tmp/fstab.out?件尾部

echo "hello world" >>/tmp/fstab.out

禁?覆盖重定向和强制重定向

set -Cecho "hello magedu" >/tmp/fstab.out-bash: /tmp/fstab.out: cannot overwrite existing file

设置禁?覆盖重定向后,可强制覆盖重定向

echo "hello magedu" >| /tmp/fstab.outcat /tmp/fstab.outhello magedu

把标准错误和标准输出分别重覆盖定向到不同的?件?,即标准错误重定向到falt.txt?件,标准输出重定向到correct.txt

which cat 2> falt.txt > correct.txtcat correct.txt/usr/bin/catcat falt.txtwih cat 2> falt.txt > correct.txtcat falt.txtcat correct.txt

合并标准输出和标准错误覆盖重定向到out.txt?件?

which cat &> out.txtcat out.txt/usr/bin/cat hich cat &>> out.txtcat out.txt/usr/bin/catbash: hich: command not found...

把所有?写字?转换为?写

tr a-z A-Z </etc/issue

把out.txt?件?的内容,写到file.txt?件?

cat >file.txt <out.txt

使?mail命令root给lsj普通?户发邮件,要求邮件标题为”help”,邮件正?如下:

Hello,I am ?户名,The system version is here,please help me to check it thanks!

*** 作系统版本信息

mail -s "help" lsj <<EOF> Hello,I am `who`,please help me to check it thanks!> `cat /etc/redhat-release`> EOF

将/etc/issue?件中的内容转换为?写后保存?/tmp/issue.out?件中

cat /etc/issue|tr ‘a-z‘ ‘A-Z‘ > /tmp/issue.out

将当前系统登录?户的信息转换为?写后保存?/tmp/who.out?件中

who |tr ‘[:lower:]‘ ‘[:upper:]‘ > /tmp/who.out或者who |tr ‘a-z‘ ‘A-Z‘ > /tmp/who.out

?个linux?户给root发邮件,要求邮件标题为”help” ,邮件正?如下: Hello,The systemversion is here,please help me to check it,thanks! *** 作系统版本信息

[[email protected] ~]# mail -s help root << EOF>Hello,I am `whoami`.>The system version is here,please help me to check it,thanks!>`cat /etc/redhat-release`>EOF

将/root/下?件列表,显?成??,并?件名之间?空格隔开

ls /root |tr ‘\n‘ ‘ ‘或: ls -1 |tr ‘\n‘ ‘ ‘

计算1+2+3+..+99+100的总和

echo {1..100} | tr ‘ ‘ + | bc

删除windows?本?件中的?^M? 字符

cat test.txt |tr -d ‘\r‘ > newtest.txt

处理字符串“xt.,l 1 jr#!$mn 2 c*/fe 3 uz 4”,只保留其中的数字和空格

echo "xt.,l 1 jr#!$mn 2 c*/fe 3 uz 4" | tr -dc ‘[:digit:][:space:]‘echo ‘xt.,l 1 jr#!$mn2 c*/fe3 uz4‘ |tr -d ‘[:punct:]‘ |tr -d ‘a-z‘

将PATH变量每个?录显?在独?的??

echo $PATH |tr ‘:‘ ‘\n‘

将指定?件中0-9分别替代成a-j

echo {0..9}|tr ‘0-9‘ ‘a-j‘

将?件/etc/centos-release中每个单词(由字?组成)显?在独???,并?空?

cat /etc/centos-release |tr -cs ‘[:Alpha:]‘ ‘\n‘
总结

以上是内存溢出为你收集整理的Linux IO和管道练习题全部内容,希望文章能够帮你解决Linux IO和管道练习题所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/yw/1030951.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-23
下一篇 2022-05-23

发表评论

登录后才能评论

评论列表(0条)

保存