linux shell系列9 统计用户的权限
#!/bin/bash
#set -x
host=`hostname`
ip=`ifconfig $(ip a|grep eth|head -n1|awk -F: '{print $2}') |grep 'inet addr:'|awk -F: '{print $2}'|awk '{print $1}'`
function pan(){
for i in $@
do
if [ $i == 'cditv' ];then
echo 0 && exit
fi
done
}
> /tmp/tttt.txt
> /tmp/temp
> /tmp/temp0
> /tmp/temp1
y=`cat /etc/passwd|grep '/bin/bash'|grep -vE 'zabbix|root|nginx|fpm|sperm'|awk -F: '{print $1}'` x=`pan $y` if [ -z $x ];then
echo -ne $host-$ip >> /tmp/temp
for i in $y
do
k=`groups $i|awk '{print $4}'`
if [ -z $k ];then
echo $i >> /tmp/temp1
elif [ $k != 'cditv' ];then
echo $i >> /tmp/temp1
elif [ $k == 'cditv' ];then
echo $i >> /tmp/temp0
fi
done elif [ $x == 0 ];then
echo -ne $host-$ip >> /tmp/temp
for i in $y
do
k=`groups $i|awk '{print $4}'`
if [ $i == 'cditv' ];then
echo $i >> /tmp/temp0
else
if [ -z $k ];then
echo $i >> /tmp/temp1
elif [ $k != 'cditv' ];then
echo $i >> /tmp/temp1
elif [ $k == 'cditv' ];then
echo $i >> /tmp/temp0
fi
fi
done fi
paste /tmp/temp /tmp/temp0 /tmp/temp1 > /tmp/tttt.txt #合成3列
rm -rf /tmp/temp /tmp/temp0 /tmp/temp1
cat /tmp/tttt.txt
echo -ne "\n"
linux shell系列9 统计用户的权限的更多相关文章
- Linux Shell系列教程之(十六) Shell输入输出重定向
本文是Linux Shell系列教程的第(十六)篇,更多Linux Shell教程请看:Linux Shell系列教程 Shell中的输出和输入的重定向是在使用中经常用到的一个功能,非常实用,今天就为 ...
- Linux Shell系列教程之(十四) Shell Select教程
本文是Linux Shell系列教程的第(十四)篇,更多Linux Shell教程请看:Linux Shell系列教程 在上一篇文章:Linux Shell系列教程之(十三)Shell分支语句case ...
- (转)Linux Shell系列教程之(十四) Shell Select教程
本文属于<Linux Shell 系列教程>文章系列,该系列共包括以下 18 部分: Linux Shell系列教程之(一)Shell简介 Linux Shell系列教程之(二)第一个Sh ...
- Linux Shell系列教程之(二)第一个Shell脚本
本文是Linux Shell系列教程的第(二)篇,更多shell教程请看:Linux Shell系列教程 通过上一篇教程的学习,相信大家已经能够对shell建立起一个大体的印象了,接下来,我们通过一个 ...
- Linux Shell系列教程之(一)Shell简介
本文是Linux Shell系列教程的第(一)篇,更多shell教程请看:Linux Shell系列教程 想要学习linux,shell知识必不可少,今天就给大家来简单介绍下shell的基本知识. S ...
- Linux Shell系列教程之(十七) Shell文件包含
本文是Linux Shell系列教程的第(十七)篇,更多Linux Shell教程请看:Linux Shell系列教程 通过文件包含,可以引用其他文件的内容,也可以将复杂内容分开,使程序结构更加清晰. ...
- Linux Shell系列教程之(十五) Shell函数简介
本文是Linux Shell系列教程的第(十五)篇,更多Linux Shell教程请看:Linux Shell系列教程 函数可以将一个复杂功能划分成若干模块,从而使程序结构更加清晰,代码重复利用率更高 ...
- Linux Shell系列教程之(十三)Shell分支语句case … esac教程
本文是Linux Shell系列教程的第(十三)篇,更多Linux Shell教程请看:Linux Shell系列教程 分支语句非常实用,基本上高级语言都支持分支语句(python 没有),大多数都使 ...
- Linux Shell系列教程之(十二)Shell until循环
本文是Linux Shell系列教程的第(十二)篇,更多Linux Shell教程请看:Linux Shell系列教程 在上两篇文章Linux Shell系列教程之(十)Shell for循环和Lin ...
随机推荐
- sublime插件不能使用,提示plugin_host has exited unexpectedly
sublime Text3一打开软件就提示plugin_host has exited unexpectedly,插件不能使用 解决方法很简单: 1.首先,ctrl + shift + p --&g ...
- [loadrunner]通过检查点判定事务是否成功
//检查点设置语句 //tmp在此时为临时参数 web_reg_find("SaveCount=tmp", "Text=xxx", LAST); ...
- Wannafly挑战赛28
总结- A-开始觉得是找规律,最开始模拟当时我觉得如果L达到1e9的范围的话,岂不是要加1e9次,模拟也就没有认真写,现在想来,后面由于加的不再是1,而是我前面的值,这样相当了一个斐波那契的类型,而斐 ...
- CONTINUE...?模拟分情况
CONTINUE...? DreamGrid has classmates numbered from to . Some of them are boys and the others are ...
- Python Revisited Day 01
逻辑操作符 身份操作符 is a = ['AAA', 3, None] b = ['AAA', 3, None] a is b #False b = a a is b #True 身份比较速度快,原因 ...
- CPU-bound(计算密集型) 和I/O bound(I/O密集型)
概念 概念I/O系统,英文全称为“Input output system”,中文全称为“输入输出系统”,由输入输出控制系统和外围设备两部分组成,是计算机系统的重要组成部分.在计算机系统中,通常把处理器 ...
- HowTos/Virtualization/VirtualBox - CentOS Wiki
https://wiki.centos.org/HowTos/Virtualization/VirtualBox
- Mysql占用CPU过高如何优化?(转)
原文:http://bbs.landingbj.com/t-0-241441-1.html MySQL处在高负载环境下,磁盘IO读写过多,肯定会占用很多资源,必然CP会U占用过高. 占用CPU过高,可 ...
- 3 Asking for more information
1 Could you tell me more about your idea? 2 Could I hear more about your idea? 3 Could you expain yo ...
- Linux启动/停止/重启Mysql数据库
1.查看mysql版本 1)status; 2)select version(); 2.Mysql启动 1)使用 service 启动: service mysqld start (5.0版本是mys ...