[英]Want to find port number from httpconf file and display it via echo command .cat httpd.conf | grep -oE “Listen'[0-9]{1,4}'”
想要從httpconf
文件中找到端口號並通過echo命令顯示它,這是我的想法,但需要進一步編輯:
cat httpd.conf | grep -oE "Listen'[0-9]{1,4}'" > echo "The port number for http is $arg{2}"
需要搜索“ Listen 80
或“ Listen <nmbr>
並獲取該數字以通過echo命令顯示。
有人可以幫忙嗎?
為什么需要cat
? 嘗試這樣的事情:
grep -i 'listen [0-9]' httpd.conf | awk '{print $2}'
用示例文件httpd.conf
測試:
測試測試
聽80 xyz
測試測試
輸出:
80
嘗試這個:
$ awk '/Listen/ {print "The port number for http is " $NF}' /etc/apache2/ports.conf
The port number for http is 80
The port number for http is 8080
The port number for http is 443
The port number for http is 443
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.