[問題] 參數/變數 置換

看板Linux作者 (海很藍,星光燦爛)時間7年前 (2017/06/01 23:12), 編輯推噓1(105)
留言6則, 4人參與, 最新討論串1/1
我有一個test_csh如下 #! /bin/csh set now_shell = "test_csh" set show_me = "inside_shell" echo "$now_shell : $show" 請問有無方法在命令列執行 test_csh 也置換變數內容 $show_me 1. 我不要$1 $2 把參數帶入 2. 我比較想要類似makefile, 如執行命令 make show_me=outside_shell -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 123.110.157.200 ※ 文章網址: https://www.ptt.cc/bbs/Linux/M.1496329935.A.0CD.html

06/02 12:33, , 1F
script 的第一行標頭就有錯吧?
06/02 12:33, 1F

06/02 13:09, , 2F
Google: shell script arguments parsing
06/02 13:09, 2F

06/02 13:11, , 3F
是有聽過c shell,但沒用過
06/02 13:11, 3F

06/02 21:53, , 4F
LANG=c ./test_csh
06/02 21:53, 4F

06/02 21:53, , 5F
可以設執行時的環境變數
06/02 21:53, 5F

06/02 21:55, , 6F
例如 foo=bar sh 開一個子 shell, echo $foo 會是 bar
06/02 21:55, 6F
文章代碼(AID): #1PC2xF3D (Linux)