如果我使用此链接安装 docker-compose,则会出现“未找到”错误:
[root@hostname ~]# curl -L "https://github.com/docker/compose/releases/download/2.9.0/docker-compose-$(uname -s)-$(uname -m)" -o here
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 9 100 9 0 0 37 0 --:--:-- --:--:-- --:--:-- 37
[root@hostname ~]# cat here
Not Found
Run Code Online (Sandbox Code Playgroud)
这是因为实际文件是docker-compose-linux-x86_64
小l
, 而:
[root@hostname ~]# echo $(uname -s)-$(uname -m)
Linux-x86_64
Run Code Online (Sandbox Code Playgroud)
它返还资本L
。
我看到man curl
但没有看到任何用于检查不区分大小写链接的条目。
我想检查命令是否正在使用以下if
子句运行,但它总是true
,无论命令实际上是否正在运行:
if [ $"(ps aux | grep curl)" ]; then echo is; else echo not; fi
Run Code Online (Sandbox Code Playgroud)
结果:
[root@is ~]# if [ $"(ps aux | grep curl)" ]; then echo is; else echo not; fi
is
Run Code Online (Sandbox Code Playgroud)
ps
外部的命令if
:
[root@is ~]# ps aux | grep curl
root 216564 0.0 0.2 6408 2064 pts/0 S+ 22:22 0:00 grep --color=auto curl
Run Code Online (Sandbox Code Playgroud)
如何检查curl
我的示例是否正在运行?
我尝试使用不同的参数ps
,但我总是有grep
命令(这在我看来是正常的),但我不知道如何检查它是否正在运行。
更新1
我想我可以做到这一点,但我不知道如何在命令中做到这一点:
if ps aux blah
if it has …
Run Code Online (Sandbox Code Playgroud) 我对此进行了一些谷歌搜索(可能是不正确的关键字),但我没有找到如何做到这一点。
考虑以下命令:
useradd -s /bin/bash -m user1
useradd -s /bin/bash -m user2
useradd -s /bin/bash -m user3
Run Code Online (Sandbox Code Playgroud)
我希望以这种方式创建的任何新用户也可以添加到名为 的组中test
,但不需要每次运行时都指定它useradd
。我希望这种情况默认发生。
我的意思是创建后user1
,当我运行时grep user1 /etc/group
,它应该分为两组:test
和user1
。
那可能吗?我正在使用 CentOS。