shell(作业一

作业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”

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值