i want to say that he is not the last user that is created. Or that he is the last user that is created.
我想说他不是最后创建的用户。或者他是最后创建的用户。
this is my script i've created:
这是我创建的脚本:
#!/bin/bash
$laatst = $(cut -d: -f1 /etc/passwd)
$laatste= $(tail -1 $laatst)
if [ $user = $laatste]
then echo "i am $user and i am created at last"
else echo "i am $user and i am not created as last"
echo "the last created user is $laatste"
fi
error: ./lastuser.sh: line 5: =root: command not found
错误:./lastuser.sh:第5行:= root:找不到命令
does anyone know why this doesn't get the last added user name and some other errors?
有谁知道为什么这不会得到最后添加的用户名和一些其他错误?
1 个解决方案
#1
0
There is no space before or after the '='. Also when setting a variable there is no dollar sign in front of the variable.
'='之前或之后没有空格。此外,在设置变量时,变量前面没有美元符号。
Also the evaluation of the string is what you are looking for and that is what is applied to your tail command.
此外,字符串的评估是您正在寻找的,这是应用于您的tail命令。
your if check needs spaces.
如果检查需要空格。
I don't see $user ever getting initialized to anything.
我没有看到$ user被初始化为任何东西。
#!/bin/bash
laatst='cut -d: -f1 /etc/passwd'
laatste=$($laatst | tail -1)
if [[ $user == $laatste ]]
then echo "i am $user and i am created at last"
else
echo "i am $user and i am not created as last"
echo "the last created user is $laatste"
fi
~
#1
0
There is no space before or after the '='. Also when setting a variable there is no dollar sign in front of the variable.
'='之前或之后没有空格。此外,在设置变量时,变量前面没有美元符号。
Also the evaluation of the string is what you are looking for and that is what is applied to your tail command.
此外,字符串的评估是您正在寻找的,这是应用于您的tail命令。
your if check needs spaces.
如果检查需要空格。
I don't see $user ever getting initialized to anything.
我没有看到$ user被初始化为任何东西。
#!/bin/bash
laatst='cut -d: -f1 /etc/passwd'
laatste=$($laatst | tail -1)
if [[ $user == $laatste ]]
then echo "i am $user and i am created at last"
else
echo "i am $user and i am not created as last"
echo "the last created user is $laatste"
fi
~