|
|||||||
| Forums | Search Forums | Register | Forum Rules | Man Pages | Albums | FAQ | Members | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Csh variable calling problem
First post on here. So I use csh shells for my research (physics... not a CS person). I am trying to rerun the same scripts, but there are ~10 files that have similar variables that I have to change for each different configuration, so I would like one central file for the variables I change that get used in the various csh files. Basically what I have been trying to do by scouring the internet but have had no success is to have a document with values: Code:
l2064f211b600m011m055m645
l2064f211b600m011m055m645b
l2064f211b600m011m055m645c
l2064f211b600m011m055m645d
('0.645 0.645 0.645' '0.011 0.011 0.011' '0.011 0.011 0.055' '0.011 0.055 0.055' '0.055 0.055 0.055')
(645 011 011m 055m 055)
1.2
1.2
1.2
64
32
36and then be able to call them in different csh files as if I had just done Code:
set mass = ('0.645 0.645 0.645' '0.011 0.011 0.011' '0.011 0.011 0.055' '0.011 0.055 0.055' '0.055 0.055 0.055'), but instead from the file (call it specs), where I could then reference it later as $mass[$1] for 0.645 0.645 0.645. I have tried to do Code:
mass=$(awk 'NR==$1' specs) , but I keep getting 'invalid variable' when I run the csh script. |
| Sponsored Links | ||
|
|
#2
|
|||
|
|||
|
Do you absolutely have to use csh? It makes everything harder.
|
| Sponsored Links | ||
|
|
#3
|
|||
|
|||
|
I would like to stay with it because I have large programs written. I knew someone would bring this up, next project I start ill change to something more modern.
|
|
#4
|
|||
|
|||
|
You are already trying to use bourne shell! $() is bourne syntax. You only get to use `` in csh. csh can't do the kind of doublethink where you put a csh statement in a variable then execute it, either. sh can, but you have to force it, since it's very seldom a good idea to do so. This will get them in an array where each number is its own index: Code:
set VAR = ( `tr -d ",()'" < infile` ) ...which you can then process with a loop to get the numbers three to an index like you want. |
| Sponsored Links | ||
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Calling awk fom csh | kristinu | Shell Programming and Scripting | 1 | 10-18-2010 07:08 PM |
| Calling awk from csh | kristinu | Shell Programming and Scripting | 2 | 06-29-2010 05:09 PM |
| Reading a variable in csh | pt14 | Shell Programming and Scripting | 4 | 06-28-2010 09:03 AM |
| calling csh script from ksh shell | JamesByars | Shell Programming and Scripting | 3 | 12-18-2008 12:52 PM |
| Calling C from within a csh script | barisgultekin | Shell Programming and Scripting | 2 | 05-24-2002 09:21 PM |
|
|