shell 脚本中带有字符串的条件 `if` 语句以不同方式配置两台计算机(Ubuntu/Gnome 与 Debian/XCFE)

Conditional `if` statement with strings in shell script to configure two computers differently (Ubuntu/Gnome vs Debian/XCFE)

我想查看 .profile 中的当前发行版,因为我有两台计算机。一个是 Ubuntu 和 Gnome,另一个是 Debian 和 XFCE。在任何一种情况下,我都希望有不同的配置,但我什至无法让以下代码在 Ubuntu:

中运行

if [[ awk '{gsub(/ /, "", ); print =}' /etc/issue == "Ubuntu" ]]; then
            gsettings set org.gnome.mutter overlay-key ''
            gsettings set org.gnome.shell.extensions.dash-to-dock hot-keys false
fi

我得到:


bash: .bashrc:223: conditional binary operator expected
bash: .bashrc:223: syntax error near `=}''
bash: .bashrc:223: `if [[ awk '{gsub(/ /, "", ); print =}' /etc/issue == "Ubuntu" ]]; then'

但据我所知,条件是正确指定的...有任何线索吗?

我建议更换

if [[ awk '{gsub(/ /, "", ); print =}' /etc/issue == "Ubuntu" ]]; then

source /etc/os-release
if [[ "$NAME" == "Ubuntu" ]]; then