![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | 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. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| assingn a variable a filename and then reading it in | magnia | UNIX for Dummies Questions & Answers | 3 | 07-23-2009 01:49 PM |
| variable used as filename | jzacsh | Shell Programming and Scripting | 4 | 05-14-2009 05:03 PM |
| Variable value not being fetched in the filename.. | RRVARMA | Shell Programming and Scripting | 3 | 06-01-2008 06:43 AM |
| mv Filename variable to another filename | gzs553 | Shell Programming and Scripting | 3 | 04-14-2008 05:19 PM |
| AWK Filename as variable | firkus | UNIX for Dummies Questions & Answers | 4 | 04-16-2004 11:50 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Inserting variable value into filename
Greetings, people of UNIX/Linux forums.
I am having a problem with a script, where I am trying to create a new variable. The value of this variable would be dependent on the value in a couple other previous variables (all variables are 2-digit integers). Here is my code: #set the stations set stn = `cat wind_obs_${date}.dat | cut -c 3-7` set mth = `cat wind_obs_${date}.dat | cut -c 10-11` set day = `cat wind_obs_${date}.dat | cut -c 13-14` set hr = `cat wind_obs_${date}.dat | cut -c 18-19` set lat = `cat wind_obs_${date}.dat | cut -c 34-38` set lon = `cat wind_obs_${date}.dat | cut -c 25-30` set nlines = `cat -b wind_obs_${date}.dat | tail -1 | cut -c 4-7` # all variables above are being set fine if (whichruc == 1) then setenv RUCDATA /ldm_data/gempak/rtma/ruc_oper set infile = ruc5_oper.2008${mth}${day}${hr}.gem #problem line else setenv RUCDATA /ldm_data/gempak/rtma/ruc set infile = ruc5_back.2008${mth}${day}${hr}.gem #problem line endif When I run this, I get an error saying: set: Variable name must begin with a letter. My variable name does begin with a letter and I cannot find a way for this to work. What should I do to ensure the value of the variables go into the file name? Thank you! |
|
||||
|
Didn't work. Same error.
I have investigated further and now think that the mth, day and hr variables are actually arrays, as they were formed by cutting/counting characters from a multi-line dat file. Any other ideas appreciated! |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|