作业1:
1、重定向和管道的区别?
2、查看指定程序httpd的进程运行状态,并将输出重定向到文件中。
3、统计系统中当前登录的用户数。
4、使用 mount 命令显示当前挂载的文件系统的信息,并使用 column 命令格式化列的输出,最后将输出结果保存到一个文件中。
5、编写第一个脚本,显示"Welcome to shell script"。
select count(1) from u_name a,u_loc b where a.userid=b.uid and a.firstname=‘John’ and b.location=‘Santa Clara’;
select firstname from u_name a,u_passwd b where a.userid=b.uid and b.password=‘fedora’;
1.重定向与管道的区别
(1)重定向分为输入与输出具有双向性,管道只能单向输入输出
2.查看进程状态,并输出定向到文件中
[root@node1 ~]# ps -aux 3306 |grep httpd
root 5162 0.0 0.0 112644 956 pts/1 R+ 19:23 0:00 grep --color=auto httpd
ps -aux 3306 |grep httpd | awk ‘{print $8}’
3.统计当前用户登录的用户数
4.使用 mount 命令显示当前挂载的文件系统的信息,并使用 column 命令格式化列的输出,最后将输出结果保存到一个文件中。
[root@node1 ~]# mount | column -s":" -t > text1
[root@node1 ~]# more text1
这个分隔符去哪了,我以为他会输出以:为分隔符,但是没有到达我的期望输出
但是就是没有分隔符,网上说是输出分隔符
5.编写第一个脚本,显示"Welcome to shell script"。
vim ~/.vimrc
autocmd BufNewFile .py,.cc,.sh,.java exec “:call SetTitle()”
func SetTitle()
if expand("%:e") == ‘sh’
call setline(1,"#!/bin/bash")
call setline(2, “##############################################################”)
call setline(3, “# File Name: “.expand(”%”))
call setline(4, “# Version: V1.0”)
call setline(5, “# Author: yyt”)
call setline(6, “# Email:yuetian_yang@163.com”)
call setline(7, “# Organization:https://blog.csdn.net/yingtongqaq/”)
call setline(8, “# Created Time : “.strftime(”%F %T”))
call setline(9, “# Description:”)
call setline(10, “##############################################################”)
call setline(11, “”)
endif
endfunc
~
vim hello.sh
echo “hello worid,welcome to shell script”