我需要一个仅在文件存在时才加载内容的脚本。 Pidgin,如果没有安装,想隐藏这个程序。我现在有这个来显示文件;
let icon = new St.Icon({icon_name: "pidgin", icon_size: ICON_SIZE, icon_type: St.IconType.FULLCOLOR});
this.filesystemItem = new MyPopupMenuItem(icon, _("Chat"));
this.menu.addMenuItem(this.filesystemItem);
this.filesystemItem.connect('activate', function(actor, event) {
Main.Util.spawnCommandLine("pidgin");
});
我只需要加载文件:/usr/share/applications/Pidgin Internet Messenger.desktop 存在。请谢谢。
最佳答案
尝试创建一个包含以下内容的 bash 文件:
#!/bin/bash
filename="/usr/share/applications/Pidgin Internet Messenger.desktop"
if [ -e "$filename" ]; then
echo "The file exists"
fi
并将其命名为 scriptName.sh
并运行它:
bash scriptName.sh
关于linux - 在 Ubuntu 中,检查文件是否存在,然后...(不是服务器),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9492454/