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 ...
随机推荐
- Spring Cloud Config 分布式配置中心【Finchley 版】
一. 介绍 1,为什么需要配置中心? 当服务部署的越来越多,规模越来越大,对应的机器数量也越来越庞大,靠人工来管理和维护服务的配置信息,变得困难,容易出错. 因此,需要一个能够动态注册和获取服务信息的 ...
- [LOJ#2386]. 「USACO 2018.01 Platinum」Cow at Large[点分治]
题意 题目链接 分析 假设当前的根为 rt ,我们能够在奶牛到达 \(u\) 之时拦住它,当且仅当到叶子节点到 \(u\) 的最短距离 \(mn_u \le dis_u\) .容易发现,合法的区域是许 ...
- shell 读取配置文件的方法
原文地址:http://bbs.chinaunix.net/thread-3628456-1-1.html 总结地址:https://www.cnblogs.com/binbinjx/p/568021 ...
- 一种简单有效的VBA源代码加密办法,支持64位宿主,适用于大部分VBA代码加密
原始出处:http://www.cnblogs.com/Charltsing/p/EncryptVBACode.html VBA代码加密是个老生常谈的问题,自从本人的VBA Dumper发布之后,在O ...
- Day3 Python基础之while、for循环(二)
1.数据运算 算数运算 整除运算:// 取余运算:% 指数运算:** 赋值运算 b+=a;等价于b=b+a 比较运算 >,<,==,!=,>=,<= 逻辑运算符 and .or ...
- iOS开发之线程组解决请求多个接口数据,完成后,再刷新界面
1.多任务请求接口,完成后,在刷新数据,常用方法 2018年07月18日 16:34:38 hbblzjy 阅读数:1382 版权声明:本文为博主原创文章,未经博主允许不得转载. https://bl ...
- Redis趣谈一则
今天看代码,无意中发现Redis中的一行注释: ; /* The world is full of Solaris Fixes */ 这行代码在bio.c文件中. 看来程序员对操作系统多样性吐槽多多啊 ...
- 什么是IaaS, PaaS和SaaS及其区别
IaaS, PaaS和SaaS是云计算的三种服务模式. . SaaS:Software-as-a-Service(软件即服务)提供给客户的服务是运营商运行在云计算基础设施上的应用程序,用户可以在各种设 ...
- git reset的用法
git reset三个选项 --mix,--hard,--soft 数据 针对每个选项都是操作这个文件. [root@centos demo]# git init Initialized empty ...
- WebSocket实现一个聊天室
聊天室页面-->index.html <!DOCTYPE html> <html> <head> <meta charset="UTF-8&q ...