当我运行以下命令时:
sudo usermod –c "Richard Tracy" dtracy
Run Code Online (Sandbox Code Playgroud)
我收到以下错误:
Usage: usermod [options] LOGIN
Options:
-c, --comment COMMENT new value of the GECOS field
-d, --home HOME_DIR new home directory for the user account
-e, --expiredate EXPIRE_DATE set account expiration date to EXPIRE_DATE
-f, --inactive INACTIVE set password inactive after expiration
to INACTIVE
-g, --gid GROUP force use GROUP as new primary group
-G, --groups GROUPS new list of supplementary GROUPS
-a, --append append the user to the supplemental GROUPS
mentioned by …
Run Code Online (Sandbox Code Playgroud) 从定位手册页:
If --regex is not specified, PATTERNs can contain globbing characters. If any PATTERN contains no globbing characters, locate behaves as if the pattern were *PATTERN*.
Run Code Online (Sandbox Code Playgroud)
现在,查看这些命令的输出:
test@ubuntu:~$ ls
Desktop Documents Downloads Firefox_wallpaper.png Music Pictures Public Templates Videos
test@ubuntu:~$
test@ubuntu:~$
test@ubuntu:~$ locate '/bin/bash*'
test@ubuntu:~$
test@ubuntu:~$
test@ubuntu:~$ locate /bin/bash*
/snap/core18/1880/bin/bash
/snap/core18/1880/usr/bin/bashbug
/snap/core18/1944/bin/bash
/snap/core18/1944/usr/bin/bashbug
/usr/bin/bash
/usr/bin/bashbug
Run Code Online (Sandbox Code Playgroud)
如果您看到我当前的工作目录没有完整路径名以/bin/bash
. 因此,我们不应该从locate /bin/bash*
. 为什么 ?根据shell 的 globbing 功能,由于我当前的工作目录中没有这样的文件/目录,因此*
不会按原样扩展和传递。因此,它应该等同于 using locate '/bin/bash*'
(这是我们上面运行的第二个命令)。因为,这没有收到任何输出,因此这locate /bin/bash*
也不应该给出输出?