作者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://webptt.com/cn.aspx?n=bbs/Linux/M.1496329935.A.0CD.html
1F:→ antontw: script 的第一行标头就有错吧? 06/02 12:33
2F:→ rickieyang: Google: shell script arguments parsing 06/02 13:09
3F:→ pili100: 是有听过c shell,但没用过 06/02 13:11
4F:推 hijkxyzuw: LANG=c ./test_csh 06/02 21:53
5F:→ hijkxyzuw: 可以设执行时的环境变数 06/02 21:53
6F:→ hijkxyzuw: 例如 foo=bar sh 开一个子 shell, echo $foo 会是 bar 06/02 21:55