csh

Difference between source and ./ execution of linux scripts

前提是你 提交于 2019-12-02 02:33:29
csh: set a=0 echo "a is $a" when i do ./my_script.csh output is: a is when i do source my_script.csh output is: a is 0 Why is it so . As i know that ./ execution uses new shell. Michał Šrajer check if variable "a" is set in your current shell: set | grep '^a=' Remember that once you source script to your current shell, all it's global variables are there until unset or you exit the current shell. You may want to start a new shell, source the script, end exit shell to perform valid tests. I don't know the context of your problem, but you may want to export some key variables to have their

Generating sequential number lists in tcsh

我是研究僧i 提交于 2019-12-02 02:12:50
问题 I've been trying to find a workaround to defining lists of sequential numbers extensively in tcsh, ie. instead of doing: i = ( 1 2 3 4 5 6 8 9 10 ) I would like to do something like this (knowing it doesn't work) i = ( 1..10 ) This would be specially usefull in foreach loops (I know I can use while, just trying to look for an alternative). Looking around I found this: foreach $number (`seq 1 1 9`) ... end Found that here. They say it would generate a list of number starting with 1, with

Self concatenate strings on csh

拟墨画扇 提交于 2019-12-01 22:06:57
问题 I need to concatenate partial content from argv to one of my variable. I will show you my code: #!/bin/csh set stringList = "" foreach param ($argv) if($param !~ TEST) then set stringList = $stringList " " $param endif end echo $stringList > /tmp/prova.txt Of course, nothing is printed on the txt file. Any solution? Thanks. 回答1: Change set stringList = $stringList " " $param to set stringList = "$stringList $param" 来源: https://stackoverflow.com/questions/13818067/self-concatenate-strings-on

In csh, why does 4 - 3 + 1 == 0?

我与影子孤独终老i 提交于 2019-12-01 15:12:54
#!/bin/csh @ cows = 4 - 3 + 1 echo $cows This simple csh script when run produces "0" for output when I'd expect "2". ~root: csh simple.1 0 I did a bunch of looking and the only thing I could think of was that the "-" was being read as a unary negation rather than subtraction, therefore changing operator precedence and ending up with 4 - 4 rather than 2 + 1. Is this correct? If so, any reason why? If not...help! Edit: So they're right associative! These operators are NOT right associative in C, are they? Is C-Shell that different from C? Paul Dixon While you are expecting the operators to be

In csh, why does 4 - 3 + 1 == 0?

社会主义新天地 提交于 2019-12-01 14:53:03
问题 #!/bin/csh @ cows = 4 - 3 + 1 echo $cows This simple csh script when run produces "0" for output when I'd expect "2". ~root: csh simple.1 0 I did a bunch of looking and the only thing I could think of was that the "-" was being read as a unary negation rather than subtraction, therefore changing operator precedence and ending up with 4 - 4 rather than 2 + 1. Is this correct? If so, any reason why? If not...help! Edit: So they're right associative! These operators are NOT right associative in

multi-line variable in tcsh

China☆狼群 提交于 2019-12-01 06:04:04
I want to have variable in tcsh to hold the usage info of my script, so in my script, whenever I write echo $usage, it will print my_script -h : -help -b : do boo etc`. Is there a way to do this? Can this be done using the << EOF ? I've tried something like this, but it failed: set help = << EOF my_script -h : print help -b : do boo EOF thanks set help = 'my_script\ -h : -help\ -b : do boo' echo $help:q Another approach: alias help 'echo "my_script" ; echo " -h : -help" ; echo " -b : do boo"' help But see also: http://www.faqs.org/faqs/unix-faq/shell/csh-whynot/ I've been using csh and tcsh

What does $?VAR mean in csh?

半城伤御伤魂 提交于 2019-12-01 06:01:11
I've encountered this code written in csh: if ( ! $?LM_LICENSE_FILE ) then setenv LM_LICENSE_FILE $_LmLicense else switch("$LM_LICENSE_FILE") case *${_LmLicense}*: breaksw default: setenv LM_LICENSE_FILE "${_LmLicense}:$LM_LICENSE_FILE" endsw endif Please note this line: if ( ! $?LM_LICENSE_FILE ) then What does $? do in $?LM_LICENSE_FILE ? LM_LICENSE_FILE is a shell variable (or macro, more precisely), and I know that $LM_LICENSE_FILE is used to retrieve its value, but a trailing question mark following $ , that is $?LM_LICENSE_FILE , what is its meaning? $?VAR expands to 1 (true) if $VAR is

multi-line variable in tcsh

*爱你&永不变心* 提交于 2019-12-01 04:06:27
问题 I want to have variable in tcsh to hold the usage info of my script, so in my script, whenever I write echo $usage, it will print my_script -h : -help -b : do boo etc`. Is there a way to do this? Can this be done using the << EOF ? I've tried something like this, but it failed: set help = << EOF my_script -h : print help -b : do boo EOF thanks 回答1: set help = 'my_script\ -h : -help\ -b : do boo' echo $help:q Another approach: alias help 'echo "my_script" ; echo " -h : -help" ; echo " -b : do

What does $?VAR mean in csh?

為{幸葍}努か 提交于 2019-12-01 03:46:51
问题 I've encountered this code written in csh: if ( ! $?LM_LICENSE_FILE ) then setenv LM_LICENSE_FILE $_LmLicense else switch("$LM_LICENSE_FILE") case *${_LmLicense}*: breaksw default: setenv LM_LICENSE_FILE "${_LmLicense}:$LM_LICENSE_FILE" endsw endif Please note this line: if ( ! $?LM_LICENSE_FILE ) then What does $? do in $?LM_LICENSE_FILE ? LM_LICENSE_FILE is a shell variable (or macro, more precisely), and I know that $LM_LICENSE_FILE is used to retrieve its value, but a trailing question

How to use parallel execution in a shell script?

耗尽温柔 提交于 2019-11-30 17:27:07
I have a C shell script that does something like this: #!/bin/csh gcc example.c -o ex gcc combine.c -o combine ex file1 r1 <-- 1 ex file2 r2 <-- 2 ex file3 r3 <-- 3 #... many more like the above combine r1 r2 r3 final \rm r1 r2 r3 Is there some way I can make lines 1 , 2 and 3 run in parallel instead of one after the another? Convert this into a Makefile with proper dependencies. Then you can use make -j to have Make run everything possible in parallel. Note that all the indents in a Makefile must be TABs. TAB shows Make where the commands to run are. Also note that this Makefile is now using