第四单元作业

1。在student用户下执行find /etc -name passwd 命令,并管理其输出要求如下

*显示所有正确输出,屏蔽错误输出


*保存正确输出到/mnt/find.out,错误输出到/mnt/find.err中(命令:find /etc -name passwd 1>/mnt/fing.out 2>/mnt/find.err)


*建立/mnt/find.all文件,并且保存所有输出到此文件(find /etc -name passwd &>/mnt/find.all)


*再次保存所有输出到/mnt/find.all中,并且保存源文件内容(find /etc -name passwd &>>/mnt/find.all)


*屏蔽此命令的所有输出((find /etc -name passwd &>/dev/null)


*显示此命令的所有输出并保存输出到桌面上的任意文件(find /etc -name passwd 2>&1 | tee ./file)


*保存正确输出到/mnt/find.out.1中,屏蔽错误输出(find /etc -name passwd 1>/mnt/find.out.1 2>/dev/null)


2.处理文件在文件/usr/share/mime/packages/freedesktop.org.xml要求如下

*找到此文件中包含ich的行,并保存这些到/root/lines中.命令(cat /usr/share/mime/packages/freedesktop.org.xml | grep ich | tee /root/lines)加上 -n 可以显示出每个包含ich的行位于原文件多少行


*用vim替换/root/lines中的空格,并且保持文件中原有的内容(vim /root/lines 打开该文件 并在命令模式下输入:%s/\ /vim/g即可)


猜你喜欢

转载自blog.csdn.net/turnaroundfor/article/details/53978992