linux shell系列9 统计用户的权限
2024-08-22 12:52:44
#!/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"
最新文章
- C#设计模式-中介者模式
- python虚拟机中的异常流控制
- 用onerror处理图片获取失败问题
- 获取iOS设备型号iphone ipad
- Tomcat7启动log打印到INFO: At least one JAR was scanned for TLDs yet contained no TLDs.就停止不动了
- JS简单的图片左右滚动
- TreeView Class Key Points
- javascript 内置对象
- C++中this指针的用法详解(转)
- CodeForces 617C【序枚举】
- Qt窗体关闭时,如何自动销毁窗体类对象
- JAVA操作数据库插入中文表中显示乱码的解决方法
- 使用RecyclerView写树形结构的TreeRecyclerView
- 类似微博菜单 ,用swift语言编写
- SQL Server(函数) 关键字的使用 三
- MyReport报表引擎2.7.6.7新功能
- CodeForces 621A Wet Shark and Odd and Even
- python数据类型(二)
- FPGA学习笔记(二)——FPGA学习路线及开发流程
- Outlook IMAP 修改PST文件存储路径
热门文章
- 深入浅出Tomcat系列
- Dockerfile centos7_tomcat7.0.64_jdk7u80
- H5 video标签的第二种格式
- codeforces#580 D. Kefa and Dishes(状压dp)
- Mysql数据库触发器调用脚本
- openstack-KVM管理工具
- pdf中内嵌字体问题
- Python爬虫:爬取人人都是产品经理的数据
- Git - 常见错误与解决方案
- echo ";"; >; 和 echo ";"; >;>; 的区别