shell脚本获取用户,并按格式输出(shell参数传递)

138 阅读1分钟

本文已参与「新人创作礼」活动,一起开启掘金创作之路。

shell脚本echo 参数传递,for循环自增,for读取列表

`#!/bin/bash

获取所有用户

function get_users { users=cat /etc/passwd | tail -n+11 | cut -d: -f1 | cut -d_ -f2 echo $users }

遍历用户列表对用户名做处理

user_list=get_users index=1 for user in userlistdoecho"Thisuser_list do echo "This index user is : user"index=user" index=(($index+1)) done`