{"id":119390,"date":"2018-09-11T08:26:58","date_gmt":"2018-09-11T00:26:58","guid":{"rendered":"https:\/\/lrxjmw.cn\/?p=119390"},"modified":"2018-09-04T10:45:43","modified_gmt":"2018-09-04T02:45:43","slug":"linux-shell-tools","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/linux-shell-tools.html","title":{"rendered":"\u51e0\u4e2a\u589e\u52a0 linux shell \u811a\u672c\u8da3\u5473\u7684\u5de5\u5177"},"content":{"rendered":"

\u6709\u4e9b\u8bef\u89e3\u8ba4\u4e3a shell \u811a\u672c\u4ec5\u7528\u4e8e CLI \u73af\u5883\u3002\u5b9e\u9645\u4e0a\u5728 KDE \u6216 Gnome \u684c\u9762\u4e0b\uff0c\u4f60\u53ef\u4ee5\u6709\u6548\u7684\u4f7f\u7528\u5404\u79cd\u5de5\u5177\u7f16\u5199 GUI \u6216\u8005\u7f51\u7edc\uff08socket\uff09\u811a\u672c\u3002shell \u811a\u672c\u53ef\u4ee5\u4f7f\u7528\u4e00\u4e9b GUI \u7ec4\u4ef6\uff08\u83dc\u5355\u3001\u8b66\u544a\u6846\u3001\u8fdb\u5ea6\u6761\u7b49\uff09\uff0c\u4f60\u53ef\u4ee5\u63a7\u5236\u7ec8\u7aef\u8f93\u51fa\u3001\u5149\u6807\u4f4d\u7f6e\u4ee5\u53ca\u5404\u79cd\u8f93\u51fa\u6548\u679c\u7b49\u7b49\u3002\u5229\u7528\u4e0b\u9762\u7684\u5de5\u5177\uff0c\u4f60\u53ef\u4ee5\u6784\u5efa\u5f3a\u58ee\u7684\u3001\u53ef\u4ea4\u4e92\u7684\u3001\u5bf9\u7528\u6237\u53cb\u597d\u7684 UNIX\/Linux bash \u811a\u672c\u3002<\/p>\n

\u5236\u4f5c GUI \u5e94\u7528\u4e0d\u662f\u4e00\u9879\u56f0\u96be\u7684\u4efb\u52a1\uff0c\u4f46\u9700\u8981\u65f6\u95f4\u548c\u8010\u5fc3\u3002\u5e78\u8fd0\u7684\u662f\uff0cUNIX \u548c Linux \u90fd\u5e26\u6709\u5927\u91cf\u7f16\u5199\u6f02\u4eae GUI \u811a\u672c\u7684\u5de5\u5177\u3002\u4ee5\u4e0b\u5de5\u5177\u662f\u57fa\u4e8e FreeBSD \u548c Linux \u64cd\u4f5c\u7cfb\u7edf\u505a\u7684\u6d4b\u8bd5\uff0c\u800c\u4e14\u4e5f\u9002\u7528\u4e8e\u5176\u4ed6\u7c7b UNIX \u64cd\u4f5c\u7cfb\u7edf\u3002<\/p>\n

1\u3001notify-send \u547d\u4ee4<\/strong><\/div>\n

notify-send<\/span> \u547d\u4ee4\u5141\u8bb8\u4f60\u501f\u52a9\u901a\u77e5\u5b88\u62a4\u8fdb\u7a0b\u53d1\u9001\u684c\u9762\u901a\u77e5\u7ed9\u7528\u6237\u3002\u8fd9\u79cd\u907f\u514d\u6253\u6270\u7528\u6237\u7684\u65b9\u5f0f\uff0c\u5bf9\u4e8e\u901a\u77e5\u684c\u9762\u7528\u6237\u4e00\u4e2a\u4e8b\u4ef6\u6216\u663e\u793a\u4e00\u4e9b\u4fe1\u606f\u662f\u6709\u7528\u7684\u3002\u5728 Debian \u6216 Ubuntu \u4e0a\uff0c\u4f60\u9700\u8981\u4f7f\u7528 apt \u547d\u4ee4<\/a>[1]<\/span> \u6216 apt-get \u547d\u4ee4<\/a>[2]<\/span> \u5b89\u88c5\u7684\u5305\uff1a<\/p>\n

sudo apt-get install libnotify-bin\r\n<\/pre>\n

CentOS\/RHEL \u7528\u6237\u4f7f\u7528\u4e0b\u9762\u7684 yum \u547d\u4ee4<\/a>[3]<\/span>\uff1a<\/p>\n

sudo yum install libnotify\r\n<\/pre>\n

Fedora Linux \u7528\u6237\u4f7f\u7528\u4e0b\u9762\u7684 dnf \u547d\u4ee4\uff1a<\/p>\n

`$ sudo dnf install libnotify`\r\nIn this example, send simple desktop notification from the command line, enter:\r\n### \u53d1\u9001\u4e00\u4e9b\u901a\u77e5 ###\r\nnotify-send \"rsnapshot done :)\"\r\n<\/pre>\n

\u793a\u4f8b\u8f93\u51fa\uff1a<\/p>\n

\"\"<\/p>\n

notify-send: Shell Script Get Or Send Desktop Notifications<\/em><\/p>\n

\u4e0b\u9762\u662f\u53e6\u4e00\u4e2a\u9644\u52a0\u9009\u9879\u7684\u4ee3\u7801\uff1a<\/p>\n

...\r\nalert=18000\r\nlive=$(lynx --dump http:\/\/money.rediff.com\/ | grep 'BSE LIVE' | awk '{ print $5}' | sed 's\/,\/\/g;s\/\\.[0-9]*\/\/g')\r\n[ $notify_counter -eq 0 ] && [ $live -ge $alert ] && { notify-send -t 5000 -u low -i   \"BSE Sensex touched 18k\";  notify_counter=1; }\r\n...\r\n<\/pre>\n

\u793a\u4f8b\u8f93\u51fa\uff1a<\/p>\n

\"\"<\/p>\n

Linux \/ UNIX: Display Notifications From Your Shell Scripts With notify-send<\/em><\/p>\n

\u8fd9\u91cc\uff1a<\/p>\n