作者sixth (海很藍,星光燦爛)
看板Linux
標題[問題] 參數/變數 置換
時間Thu Jun 1 23:12:13 2017
我有一個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
→ antontw: script 的第一行標頭就有錯吧? 06/02 12:33
→ rickieyang: Google: shell script arguments parsing 06/02 13:09
→ pili100: 是有聽過c shell,但沒用過 06/02 13:11
推 hijkxyzuw: LANG=c ./test_csh 06/02 21:53
→ hijkxyzuw: 可以設執行時的環境變數 06/02 21:53
→ hijkxyzuw: 例如 foo=bar sh 開一個子 shell, echo $foo 會是 bar 06/02 21:55