Awk
我想將輸出替換為文本
我有以下程式碼。
curl -X POST --data-urlencode 'payload={"channel": "#general", "username": "webhookbot", "text": "This is posted to #general and comes from a bot named webhookbot.", "icon_emoji": ":ghost:"}' https://hooks.slack.com/services/xxxxxxxxxxxxxxxxxxxx
這個命令發送
This is posted to #general and comes from a bot named webhookbot
到Slack Channel
,現在我想用輸出替換這個wc -l ips.txt | awk '{print $1}'
我要這個 :
curl -X POST --data-urlencode 'payload={"channel": "#general", "username": "webhookbot", "text": "OUTPUT OF wc -l command , like number 154", "icon_emoji": ":ghost:"}' https://hooks.slack.com/services/xxxxxxxxxxxxxxxxxxxx
我該怎麼做 ?
curl -X POST --data-urlencode "payload={'channel': '#general', 'username': 'webhookbot', 'text': \"$(wc -l ips.txt | awk '{print $1}')\", 'icon_emoji': ':ghost:'}" https://hooks.slack.com/services/xxxxxxxxxxxxxxxxxxxx
您應該能夠使用反引號進行命令擴展:
curl -X POST --data-urlencode 'payload={"channel": "#general", "username": "webhookbot", "text": "`wc -l ips.txt | awk '{print $1}'`", "icon_emoji": ":ghost:"}' https://hooks.slack.com/services/xxxxxxxxxxxxxxxxxxxx