- 论坛徽章:
- 0
|
本帖最后由 LIerWx 于 2016-10-20 16:47 编辑
如题,我的文本是下面这样
- ## Next comes the main part: which users can run what software on
- ## which machines (the sudoers file can be shared between multiple
- ## systems).
- ## Syntax:
- ##
- ## user MACHINE=COMMANDS
- ##
- ## The COMMANDS section may have other options added to it.
- ##
- ## Allow root to run any commands anywhere
- root ALL=(ALL) ALL
- * *=(*) ALL
- * *=(aaa) ALL
- ## Allows members of the 'sys' group to run networking, software,
- ## service management apps and more.
- # %sys ALL = NETWORKING, SOFTWARE, SERVICES, STORAGE, DELEGATING, PROCESSES, LOCATE, DRIVERS
- ## Allows people in group wheel to run all commands
- %wheel ALL=(ALL) ALL
- ## Same thing without a password
- # %wheel ALL=(ALL) NOPASSWD: ALL
- ## Allows members of the users group to mount and unmount the
- ## cdrom as root
- # %users ALL=/sbin/mount /mnt/cdrom, /sbin/umount /mnt/cdrom
复制代码 我在脚本里判断时要打印信息,如下:
- [root@localhost ~]#
- [root@localhost ~]# cat /etc/sudoers | sed -r '/^\s*\*\s+\*=\(\*\)\s+ALL\s*$/!d'
- * *=(*) ALL
- [root@VM1 ~]#
复制代码
但我在echo `cat /etc/sudoers | sed -r '/^\s*\*\s+\*=\(\*\)\s+ALL\s*$/!d'` 时,却把当前目录的内容也打印出来了 最后那段才是我要的信息,要如何只显示命令输出内容?
- [root@localhost ~]# echo `cat /etc/sudoers | sed -r '/^\s*\*\s+\*=\(\*\)\s+ALL\s*$/!d'`
- a.md5 anaconda-ks.cfg a.sh a.txt auth_14.sh AUTH_15.sh b.sh Desktop Documents Downloads Music mysql-5.7.14-linux-glibc2.5-x86_64.tar.gz nginx-1.11.4 nginx-1.11.4.tar.gz php-5.6.26 php-5.6.26.tar.gz Pictures Public Templates Videos zabbix-3.0.0beta1 zabbix-3.0.0beta1.tar.gz *=(*) ALL
- [root@localhost ~]#
复制代码
|
|