1、将/etc/issue文件中的内容转换为大写后保存至/tmp/issue.out文件中
[root@centos7 ~]#cat /etc/issue | tr ‘[:lower:]’ ‘[:upper:]’ > /tmp/issue.out
[root@centos7 data]# tr ‘[:lower:]’ ‘[:upper:]’ < /etc/issue > /tmp/issue.log
2、将当前系统登录用户的信息转换为大写后保存至/tmp/who.out文件中
[root@centos7 ~]#who | tr ‘[:lower:]’ ‘[:upper:]’ | tee /tmp/who.out
[root@centos7 /]#who | tr ‘[:lower:]’ ‘[:upper:]’ > /tmp/who.out
3、一个linux用户给root发邮件,要求邮件标题为”help” ,邮件正文如下:
Hello, I am 用户名,The system version is here,please help me to check it ,thanks!
操作系统版本信息
[root@centos7 Packages]#mail -s help root <<EOF
Hello, I am $USER ,The system version is here,please help me to check it ,thanks!
OS version info
$(lsb_release)
EOF
4、将/root/下文件列表,显示成一行,并文件名之间用空格隔开
[root@centos7 ~]#ls /root/ | tr -s ‘\n’ ’ ’
5、计算1+2+3+…+99+100的总和
[root@centos7 ~]#echo {1…100} | tr ’ ’ ‘+’ |bc
[root@centos7 ~]#seq -s + 100 |bc
6、删除Windows文本文件中的‘^M’ 字符
7、处理字符串“xt.,l 1 jr#!$mn 2 c*/fe 3 uz 4”,只保留其中的数字和空格
[root@centos7 ~]#echo “xt.,l 1 jr#bcmn 2 c*/fe 3 uz 4” | tr -dc ‘[:digit:][:blank:]’
[root@centos7 ~]#echo “xt.,l 1 jr#bcmn 2 c*/fe 3 uz 4” | tr -dc '0-9 ’
8、将PATH变量每个目录显示在独立的一行
[root@centos7 ~]#echo $PATH | tr ‘:’ ‘\n’
9、 将指定文件中0-9分别替代成a-j
[root@centos7 data]#tr ‘0-9’ ‘a-j’ < 2e
10、将文件/etc/centos-release中每个单词(由字母组成)显示在独立的一行,并无空行
[root@centos7 data]#cat /etc/centos-release | tr ’ ’ ‘\n’
https://blog.csdn.net/qq_37996875/article/details/81278996