我在我的bashrc文件中有一個別名,用於輸出當前文件夾內容和系統可用存儲,並通過watch函數不斷更新。在bash腳本中需要幫助從awk引用轉義
alias wtch='watch -n 0 -t "du -sch * -B 1000000 2>/dev/null | sort -h && df -h -B 1000000| head -2 | awk '{print \$4}'"'
該字符串工作正常,直到我把awk部分。我知道我需要避開單引號,同時仍然留在雙引號和$ 4中,但是我一直無法使其工作。我究竟做錯了什麼?
這是錯誤我得到
-bash: alias: $4}": not found
@EdMorton再次感謝埃德!我一如既往地採納了你的建議(主要是) –