csh: usages

  • special symbol
    • scripts contant
#!/bin/tcsh

echo \$_ : $_
echo \$0 : $0
echo \$1 : $1
echo \$\* : $*
echo \$\# : $#
echo \$\$ : $$
echo \$! : $!
echo \$\? : $?
    • run this script
% source test.csh a b c

> $_ : source test.csh a b c 
> $0 : -tcsh
> $1 : a
> $* : a b c
> $# : 3
> $$ : 18300
> $! :
> $? : 0
  • Get the executing script's path
    • script name: test.csh
#!/bin/tcsh

set called=($_)
set envfile = `echo $called | awk '{print $2}'| xargs basename`
set path = `echo $called | awk '{print $2}'| xargs readlink -f | xargs dirname`

echo "envfile: $envfile"
echo "path: $path"
    • run test.csh
% source test1.csh

> envfile = test1.tcl
> path = <the script's full path>

 

 

 

posted @ 2020-09-25 21:47  cynn  阅读(149)  评论(0)    收藏  举报