for脚本循环
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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
执行结果
[[email protected] ~]# 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脚本循环的主要内容,如果未能解决你的问题,请参考以下文章
如何在 Toad for Oracle 中使用自定义代码片段?
c_cpp 这个简单的代码片段显示了如何使用有符号整数在C中完成插值。 for()循环确定要插入的范围
在 Activity 内部,如何暂停 for 循环以调用片段,然后在按钮单击片段后恢复循环以重新开始