搜尋後透過連接埠路徑 cd 的 tcsh 別名

搜尋後透過連接埠路徑 cd 的 tcsh 別名

現在我嘗試為此命令創建一個別名:

alias cdport    'cd `whereis \!^ | awk \'{print $2}\'`'

找不到在序列中使用 2 個以上命令的任何好範例。

如何修復該程式碼?謝謝。

答案1

您無法在 csh 中轉義字串中的引號。您需要切換到雙引號字串來輸入這些字元:

alias cdport 'cd `whereis \!^ | awk '"'"'{sub("/[^/]*$", "/", $2); print $2}'"'"'`'

我還修復了awk腳本以從 的輸出中刪除文件名whereis,因此您只需獲取目錄部分。

相關內容