Sponsored Content
Top Forums Shell Programming and Scripting Inserting variable value into filename Post 302347024 by TheSMan5 on Monday 24th of August 2009 05:35:47 PM
Old 08-24-2009
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!
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

mv Filename variable to another filename

Anyone who can assist : I am trying to pass the group vairiable to a filename: rpt_tsavegrp=/export/legato/scripts/$group_savegrp_rpt.$dat It will not pass to variable. Anyone have any ideas what I am doing wrong here. Thanks # This script sends email that save group completed.... (3 Replies)
Discussion started by: gzs553
3 Replies

2. Shell Programming and Scripting

Inserting a line when its length is variable

Hi Unix experts I have simple text files in which the number of lines vary from one file to another. They look like the following: # # . . 34 46 76 72 39 68 I want to grab the first number of the last line of each file (let's say A= 39 in the above example), which is... (2 Replies)
Discussion started by: nxp
2 Replies

3. Shell Programming and Scripting

Inserting text to file, sed and variable not acting right

I want to put text stored in a variable into a file on the 7th line. I'm having trouble with this line: sed '7i\'$text'' $file It works perfectly for a single word, but fails if there are two words because of the space. I've tried several forms of quoting and this is the only one that... (2 Replies)
Discussion started by: fubaya
2 Replies

4. Shell Programming and Scripting

inserting a variable to a new line

In my script I am using sed to insert a line. Suppose I have a variable called ck_size=5 and a temporary file called tmp I want to add a certain line in the tmp file .Please see the below command sed -i '2a\maitee is $ck_size' /dun/homes/lrsprod/tmp I want in 2 line of tmp file... (7 Replies)
Discussion started by: maitree
7 Replies

5. UNIX for Dummies Questions & Answers

awk for inserting a variable containing single and double quotes

Hi i have to insert the below line into a specific line number of another file export MBR_CNT_PRCP_TYPE_CODES_DEL="'01','02','04','05','49','55','UNK'" I have passed the above line to a variable say ins_line. I have used below command to perform the insert awk 'NR==3{print "'"${ins_line}"'"}1'... (1 Reply)
Discussion started by: sathishteradata
1 Replies

6. Shell Programming and Scripting

Inserting variable values in filename

Hi All, I have a directory containing multiple files. and also a txt file which contains the list of all filenames and certain values. I want to read the text file line by line and if its 2nd column is matched with the filename in directory, then it must insert the values in 7th column to... (14 Replies)
Discussion started by: CAch
14 Replies

7. Shell Programming and Scripting

Inserting filename at the top of file

Hi Forum members, I want to insert the filename at the top of file (i.e, first row only) My file name is like asdf_432 And I want to insert this filename in first row as filename is asdf with serial no. 432 Thanks in advance. :) (4 Replies)
Discussion started by: CAch
4 Replies

8. Shell Programming and Scripting

Problem in inserting values of variable of shell

hi all, i have one shell script like this #!/bin/bash -xv ENV_NAME=`cat $IB_HOME_DIR/cfg/ibProfile.sh | grep "RDM_CONN" | cut -f 2 -d "@"` CURRENT_DIR=`pwd`; string=$IB_HOME_DIR string1="$string/FRGFOLDER/input" #sed "s/string3/$string1" frg_event_src.sql > modifiedinsert.sql sqlplus... (2 Replies)
Discussion started by: ramsavi
2 Replies

9. Shell Programming and Scripting

Bash - Inserting non printable character(s) in string variable

Hello. I have a string variable named L_TEMP to test a very simple filter. L_TEMP="50AwL.|KWp9jk" I want to insert a non printable character between K and W. I have try this : linux-g65k:~ # a='50AwL.|K' linux-g65k:~ # b='Wp9jk' linux-g65k:~ # L_TEMP="$a$'\x07'$b" linux-g65k:~ # echo... (6 Replies)
Discussion started by: jcdole
6 Replies

10. UNIX for Dummies Questions & Answers

Inserting a variable in awk script

I have file input.txt: >TX1-1 Freq 55 cattctgatgaatatttgtcctttagttgttatttgt >TX1-2 Freq 19 cattctgatgaatatttgtcctttagttgttatttgt >TX1-3 Freq 17 cattctgatgaatatttgtcctttagttgttatttgt >TX1-4 Freq 6 cattctgatgaatatttgtcctttagttgttatttgt >TX1-5 Freq 6 cattctgatgaatatttgtcctttagttgttatttgt ... (5 Replies)
Discussion started by: Xterra
5 Replies
MUPLOT(1)							   User Commands							 MUPLOT(1)

NAME
muplot - plot a multi-curve figure from multiple data by using Gnuplot SYNOPSIS
muplot [OPTION]... [STYLE] [FILE] [AXES] [FILE] [AXES] ... DESCRIPTION
Muplot is a simple, non-interactive gnuplot-wrapper to plot a multi-curve figure from multiple data (files). It can produce PostScript, PDF, PNG or JPEG output file formats. OPTIONS
--help|-H display help --version output version and license message -h display short help -V print program version number -s create PostScript file -S send PostScript output to STDOUT (the same as '-s -o -') -n create PNG file -j create JPEG file -p create PDF file (requires the gnuplot "pdfcairo" driver) -c <cmd> execute gnuplot command(s) (the default plot style is used) -m monochrome plot (valid only for PostScript) -l set plot size to 800x600 (valid for PNG and JPEG) -o base name of the output file -q quiet mode (all messages except errors to be suppressed) -i ignore local command file './.muplotset' -I <file> specify an alternative command file instead of './.muplotset' Styles: l lines p points lp lines and points (default) pp circle points d dots b boxes g grid e errorbars - default used columns are 1:2:3 (x:y:yerror) a fields with arrows; The data file has a special format in this case. Use 'prefield' to prepare such data files. dt=<fmt> date/time series with the specified format; For example: dt="%H:%M.%S@%H:%M" where the first part, in front of "@", defines the data format, and the second part defines the format that will be used for tic labels. Here, hours and minutes are separated by `:', respectively minutes and seconds by `.' Another example could be a date: dt="%Y-%m-%d". u=<fmt> user specified format as defined in Gnuplot Axes: x:y,x:y-z columns in the file defining the x/y-axes of the curve(s); Default are 1:2 or 1:2:3 for data with errors. In case that only one col- umn is provided the default axes are 0:1 - the x-axis will be a simple index then. File(s) could be a single file name whereas '-' means <stdin>, many files enclosed in '' or "" like "file1 file2 file3", or any valid shell pattern as for example "*.dat". The files '$HOME/.muplotset' and './.muplotset', if existing, will be included at the beginning of the gnu- plot script. The command block between "#BEGIN" and "#END" in those files will be pasted to the end of the script. If you want that the global '$HOME/.muplotset' is ignored, create in your local directory a file named '.muplotset.noglobal'. In case you want to view the out- put, define the env variable MUPLOT_VIEWER and export it, for example: MUPLOT_VIEWER="xpdf -z page"; export MUPLOT_VIEWER Then the program will prompt you to view the plot, and after confirmation the viewer will present the graphics. If the postscript file for- mat is chosen ('-s' option), and MUPLOT_VIEWER is not defined, the viewer is preset to 'gv', and per default you are prompted to view the output. To disable this behavior, set MUPLOT_VIEWER="". EXAMPLES
1) On X-terminal view a multi-curve plot of data files with extension 'dat' muplot l "*.dat" 2) Print a sinus curve in black-and-white color on a PostScript printer muplot -m -S -c "set title 'Function f(x)=sin(x)'; plot sin(x);" | lpr 3) Plot data from file "example.dat" using columns 1:2, 3:4, and 3:5 as x/y-axes in the multi-curve plot; a PostScript file with the name "example.ps" is automatically created. muplot -s lp example.dat 1:2,3:4-5 4) Create graphics in PDF format reading data from file "example.1.dat" (columns 1:2), and from file "example.2.dat" (columns 3:4) muplot -p lp example.1.dat 1:2 example.2.dat 3:4 5) View data where the third column is a date of the form 'yyyy-mm-dd' cat example_counts_per_day.dat | muplot dt="%Y-%m-%d" - 3:1 REPORTING BUGS
Report bugs to <gnu@mirendom.net> COPYRIGHT
Copyright (C) 1996-2009, 2011-2012 Dimitar Ivanov License: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. muplot 3.2.1 February 2012 MUPLOT(1)
All times are GMT -4. The time now is 01:20 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy