作业练习-3

1、将/etc/issue文件中的内容转换为大写后保存至/tmp/issue.out文件中
2、将当前系统登录用户的信息转换为大写后保存至/tmp/who.out文件中
3、一个linux用户给root发邮件,要求邮件标题为”help”,邮件正文如下:
Hello, I am 用户名,The system version is here,please help me to check it ,thanks!
操作系统版本信息
4、将/root/下文件列表,显示成一行,并文件名之间用空格隔开
5、计算1+2+3+...+99+100的总和
6、删除Windows文本文件中的回车字符 ,即“\r”
7、处理字符串“xt.,l 1 jr#!$mn 2 c*/fe 3 uz 4”,只保留其中的数字和空格
8、将PATH变量每个目录显示在独立的一行
9、将指定文件中0-9分别替代成a-j
10、将文件/etc/centos-release中每个单词(由字母组成)显示在独立一行,并无空行

-------------------------------------------------------------------------------------------------------------------------------------

[root@Centos7 ~]# cat /etc/issue | tr 'a-z' 'A-Z' > /tmp/issue
[root@Centos7 ~]# cat /tmp/issue
\S
KERNEL \R ON AN \M


[root@Centos7 ~]# who | tr 'a-z' 'A-Z' > /tmp/who.out
[root@Centos7 ~]# cat /tmp/who.out
ROOT     TTY1         2021-02-13 13:56
ROOT     PTS/0        2021-02-13 13:57 (192.168.8.131)


1.多行重定向方式
[litao@Centos7 ~]$  mail -s hello1 root <<EOF
> Hello, I am `hostname`
> The system version is here,please help me to check it ,thanks!
> `cat /proc/version`
> EOF
2.文本重定向
cat mail.log | mail -s help2 root


[root@Centos7 ~]# ls /root/ |tr '\t' ' '
anaconda-ks.cfg
filea.log
fileb.log
filec.log
filed.log
tr


[root@Centos7 ~]# echo {1..100}
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100
[root@Centos7 ~]# echo {1..100} | tr -s ' ' +
1+2+3+4+5+6+7+8+9+10+11+12+13+14+15+16+17+18+19+20+21+22+23+24+25+26+27+28+29+30+31+32+33+34+35+36+37+38+39+40+41+42+43+44+45+46+47+48+49+50+51+52+53+54+55+56+57+58+59+60+61+62+63+64+65+66+67+68+69+70+71+72+73+74+75+76+77+78+79+80+81+82+83+84+85+86+87+88+89+90+91+92+93+94+95+96+97+98+99+100
[root@Centos7 ~]# echo {1..100} | tr -s ' ' + | bc
5050
[root@Centos7 ~]# seq -s + 1 100
1+2+3+4+5+6+7+8+9+10+11+12+13+14+15+16+17+18+19+20+21+22+23+24+25+26+27+28+29+30+31+32+33+34+35+36+37+38+39+40+41+42+43+44+45+46+47+48+49+50+51+52+53+54+55+56+57+58+59+60+61+62+63+64+65+66+67+68+69+70+71+72+73+74+75+76+77+78+79+80+81+82+83+84+85+86+87+88+89+90+91+92+93+94+95+96+97+98+99+100
[root@Centos7 ~]# seq -s + 1 100 | bc
5050


tr -d '\r' < win.txt >win1.txt
[root@Centos7 ~]# cat -A win1.txt
Hello, I am litao$
i love you[root@Centos7 ~]# cat win.txt
Hello, I am litao
i love you[root@Centos7 ~]# cat -A win.txt
Hello, I am litao^M$


[root@Centos7 ~]# echo  'xt.,l 1 jr#4"mn 2 c*/fe 3 uz 4' | tr -d '[[:alpha:][:punct:]]'
 1 4 2  3  4


[root@Centos7 ~]# echo $PATH
/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin
[root@Centos7 ~]# echo $PATH | tr -s ':' '\n'
/usr/local/sbin
/usr/local/bin
/sbin
/bin
/usr/sbin
/usr/bin
/root/bin


[root@Centos7 ~]# echo {1..9} >test
[root@Centos7 ~]# cat test
1 2 3 4 5 6 7 8 9
[root@Centos7 ~]# cat test | tr '1-9' 'a-j'
a b c d e f g h i


[root@Centos7 ~]# cat /etc/centos-release | tr -s ' ' '\n'
CentOS
Linux
release
7.9.2009
(Core)
posted @ 2021-02-13 19:22  湘北10#  阅读(122)  评论(0编辑  收藏  举报