码迷,mamicode.com
首页 > 其他好文 > 详细

马哥教育面授班-标准I/O和管道-课后小作业-2016年7月28

时间:2016-08-01 23:16:03      阅读:466      评论:0      收藏:0      [点我收藏+]

标签:用户名   linux   管道   


马哥教育面授班-7月28号作业


1 、将/etc/issue 文件中的内容转换为大写后保存至/tmp/issue.out 文件中

[root@localhost ~]# tr ‘a-z‘ ‘A-Z‘ </etc/issue | >> /tmp/issue.out
[root@localhost ~]# cat /tmp/issue.out 
CENTOS RELEASE 6.8 (FINAL)
KERNEL \R ON AN \T \N
\D \S
MAGE EDUCATION LEARNING SERVICES
HTTP://WWW.MAGEDU.COM
[root@localhost ~]#

2 、将当前系统登录用户的信息转换为大写后保存至/tmp/who.out 文件中

[root@localhost ~]# whoami | tr ‘a-z‘ ‘A-Z‘ >/tmp/who.out
[root@localhost ~]# cat /tmp/who.out 
ROOT

3 、一个linux 用户给root 发邮件,要求邮件标题为”help” ,邮件正文如下:

Hello, Iam  用户名,thesystem version is here,please help me to

check it,thanks!

操作系统版本信息

[root@localhost ~]# echo -e "Hello, I am `whoami` ,the system version is here,please help me to \ncheck it ,thanks! \n`cat /etc/centos-release`" | mail -s "help" root
[root@localhost ~]# cat /var/spool/mail/root

效果图

技术分享

4 、将/root/ 下文件列表,显示成一行,并文件名之间用空格隔开

[root@localhost ~]# ls -1 | tr ‘\n‘ ‘ ‘
1.log 2.log aa [a,b,c,d,e,f [a-c] anaconda-ks.cfg etcs f f[a-c] file1 install.log install.log.syslog mail mail.txt network pass testdir w2c

5 file1 文件 内容为:”1 2 3 4 5 6 7 89 10”  计算出所有数字的总和

[root@localhost ~]# echo "1 2 3 4 5 6 7 8 9 10" > file1 | cat file1 | tr ‘ ‘ ‘+‘ | bc
55

6 、删除Windows 文本文件中的‘^M‘ 字符

[root@localhost ~]# echo "Windows" | tr -d "W"
indows

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

[root@localhost ~]# echo "xt.,|1 jr#/rootmn 2 c*/fe 3 uz 4" | tr -d -c ‘0-9 \n‘
1  2  3  4

 


本文出自 “家住海边喜欢浪” 博客,请务必保留此出处http://zhang789.blog.51cto.com/11045979/1833102

马哥教育面授班-标准I/O和管道-课后小作业-2016年7月28

标签:用户名   linux   管道   

原文地址:http://zhang789.blog.51cto.com/11045979/1833102

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!