我试图让这个脚本工作,但我得到的是:
14:语法错误:“(”意外(期望“fi”)。
希望你们能解决我的问题,因为我调查错误已经有一段时间了...如果您需要该.csv文件,请告诉我。
这是脚本:
#!/bin/bash
filein="proyecto3.csv"
IFS=$'\n'
if [ ! -f "$filein" ]
then
echo "Cannot find file $filein"
else
groups=(`cut -d: -f 6 "$filein" | sed 's/ //'`)
fullnames=(`cut -d: -f 1 "$filein"`)
userid=(`cut -d: -f 2 "$filein"`)
usernames=(`cut -d: -f 1 "$filein" | tr [A-Z] [a-z] | awk '{print substr($1,1,1) $2}'`)
fi
for group in ${groups[*]}
do
grep -q "^$group" /etc/group ; let x=$?
if [ $x -eq 1 ]
then
groupadd "$group"
fi
done
x=0 …Run Code Online (Sandbox Code Playgroud)