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)