Linux 如何使用.info文件启动shell脚本?

Linux 如何使用.info文件启动shell脚本?,linux,shell,unix,command-line,Linux,Shell,Unix,Command Line,我的一个朋友已经开始学习shell脚本并完成了一个小任务,但他不知道如何以及从哪里开始 Problem statement is: a. Create a file 'user_UserID.info' file under /tmp. Populate the file 'user_UserID.info' with the following data: Username,Password,PrimaryGroup,Comment,HomeDir b. Create a Shell sc

我的一个朋友已经开始学习shell脚本并完成了一个小任务,但他不知道如何以及从哪里开始

Problem statement is:

a. Create a file 'user_UserID.info' file under /tmp. Populate the file 'user_UserID.info' with the following data:
Username,Password,PrimaryGroup,Comment,HomeDir

b. Create a Shell script to add user accounts and set the password for the users listed in 'user_UserID.info' file. All other 
dependent activities like group creation, directory creation etc. also should be done through this script.

c. Display the content of /home directory on console. Redirect the newly created 3 user’s information to userdetails_UserID.txt

在这里,如何创建.info文件以及它的用途是什么

请建议。任何建议或好的资源都会有帮助


谢谢。

简单脚本,你可以在互联网上找到数百万个这样的脚本,只需搜索

#!/bin/bash 

while read line
do
                USERNAME=$(echo $line | awk -F ',' '{print $1}')
                PASSWORD=$(echo $line | awk -F ',' '{print $2}')
                PRIMARY_GROUP=$(echo $line | awk -F ',' '{print $3}')
                COMMENT=$(echo $line | awk -F ',' '{print $4}')
                HOME_DIR=$(echo $line | awk -F ',' '{print $5}') 

                groupadd $PRIMARY_GROUP
                useradd -mc $COMMENT -s /bin/bash -d $HOME_DIR $USERNAME -g $PRIMARY_GROUP
                yes "$PASSWORD" | passwd $USERNAME
done < ./user_UserID.info
#/bin/bash
读行时
做
用户名=$(echo$行| awk-F','{print$1}')
密码=$(echo$行| awk-F','{print$2}')
PRIMARY_GROUP=$(echo$行| awk-F',“{print$3}”)
注释=$(echo$行| awk-F',“{print$4}”)
HOME_DIR=$(echo$行| awk-F',“{print$5}”)
组添加$PRIMARY\u组
useradd-mc$COMMENT-s/bin/bash-d$HOME\u DIR$USERNAME-g$PRIMARY\u GROUP
是“$PASSWORD”| passwd$USERNAME
完成<./user\u UserID.info

谢谢。您能否分享一些参考链接以进一步了解shell脚本。@用户_1191确认答案如果解决了您的问题,谢谢。