首页 > 代码库 > for脚本循环
for脚本循环
依次向/etc/passwd中的每个用户问好,并显示对方的shell
#!/bin /bash # for I in `cut -d ":" -f1 /etc/passwd`;do B=`grep "^$I\>" /etc/passwd | cut -d ":" -f7` echo "hello, $I your bash is $B " done
执行结果
[root@localhost ~]# bash ./helloeveryone.sh hello, root your bash is /bin/bash hello, bin your bash is /sbin/nologin hello, daemon your bash is /sbin/nologin hello, adm your bash is /sbin/nologin hello, lp your bash is /sbin/nologin hello, sync your bash is /bin/sync hello, shutdown your bash is /sbin/shutdown hello, halt your bash is /sbin/halt hello, mail your bash is /sbin/nologin hello, uucp your bash is /sbin/nologin hello, operator your bash is /sbin/nologin hello, games your bash is /sbin/nologin hello, gopher your bash is /sbin/nologin hello, ftp your bash is /sbin/nologin hello, nobody your bash is /sbin/nologin hello, dbus your bash is /sbin/nologin hello, usbmuxd your bash is /sbin/nologin hello, vcsa your bash is /sbin/nologin hello, rtkit your bash is /sbin/nologin hello, avahi-autoipd your bash is /sbin/nologin hello, pulse your bash is /sbin/nologin hello, haldaemon your bash is /sbin/nologin hello, ntp your bash is /sbin/nologin hello, apache your bash is /sbin/nologin hello, saslauth your bash is /sbin/nologin hello, postfix your bash is /sbin/nologin hello, abrt your bash is /sbin/nologin hello, gdm your bash is /sbin/nologin hello, sshd your bash is /sbin/nologin hello, tcpdump your bash is /sbin/nologin hello, my123 your bash is /bin/bash hello, qms your bash is /bin/bash hello, myhorace your bash is /sbin/nologin hello, user your bash is /bin/bash hello, hadoop your bash is /bin/bash hello, mandriva your bash is /bin/bash hello, fedora your bash is /bin/tcsh hello, hive your bash is /bin/tcsh hello, user11 your bash is /bin/bash hello, user12 your bash is /bin/bash hello, user13 your bash is /bin/bash
for脚本循环
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。