您正在执行命令替换set。在命令替换块内设置的变量在展开后被丢弃。您需要的是命令替代grep top def.tcl | tail -1 | item 2:
alias unit "set unit = "\""`grep top def.tcl | tail -1 | item 2`"\"""
alias ipcd 'unit ; cd flow/$unit/ip/'
如果你想让它成为一个函数,请在.cshrc或.tcshrc中设置以下内容:
alias function 'set argv = ( \!* ) ; source ~/.cshfuncs'
然后将函数添加到.cshfuncs:
# Functions for C Shell.
set ret = -1
onintr exit
switch ("$1")
case "ipcd":
set unit = "`grep top def.tcl | tail -1 | item 2`"
cd "flow/$unit/ip/"
set ret = 0
breaksw
case "myfunc":
echo "A function."
set ret = 0
breaksw
default:
echo "Function $1 not set."
endsw
exit:
set argv
exit $ret
1条答案
按热度按时间nimxete21#
您正在执行命令替换
set
。在命令替换块内设置的变量在展开后被丢弃。您需要的是命令替代grep top def.tcl | tail -1 | item 2
:如果你想让它成为一个函数,请在
.cshrc
或.tcshrc
中设置以下内容:然后将函数添加到
.cshfuncs
: