Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在编写一个脚本,允许用户删除其他用户。我希望用户能够添加要删除的用户列表作为参数,但我不确定您如何让用户添加任意数量的参数。我想我必须做一个循环,也许?脚本的其余部分已准备就绪,但我的小脑袋似乎在为简单的任务而苦苦挣扎。
我想你会喜欢这个:
#!/bin/sh users=$@ for duser in $@ do userdel $duser [ $? -eq 0 ] && { echo "User $duser deleted successed!" }||{ echo "User $duser deleted failed!" } done