Problem in staring a file name to variable


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Problem in staring a file name to variable
# 1  
Old 09-04-2014
Problem in staring a file name to variable

Hi All,

I have a script in which i want to store my file name in a variable named "FILE", below is the approach i am using :
Code:
mydate=`date +%d%m%Y`
DATE=`date +%Y-%m-%d`
FILE=`"FOS_TSM_ZBH_TER_$mydate.csv"`
echo "$FILE"
echo "$mydate"

on executing the above script, i am getting :
HTML Code:
b.sh: line 3: FOS_TSM_ZBH_TER_04092014.csv: command not found
Why am i getting "command not found" when i am not really executing a command, just trying to store name i a variable.
# 2  
Old 09-04-2014
try
Code:
mydate=`date +%d%m%Y`
FILE="FOS_TSM_ZBH_TER_$mydate.csv"
echo $FILE
FOS_TSM_ZBH_TER_04092014.csv

# 3  
Old 09-04-2014
Thanks Makarand,

Its working fine. Could you please also explain the reason for choosing ""
# 4  
Old 09-04-2014
Because FOS_TSM_ZBH_TER_$mydate.csv is not command and is variable value
we generaly use ` ` to enclose unix command
# 5  
Old 09-04-2014
Not 'generally' -- always. That's they're for. ` ` run the text they enclose as a command.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Problem to match a path in a file and put it into a variable

Hello,:p I made a script which do a backup on remote servers with a rsync command. I have a config.cfg with the IPs and the paths where it will copy the directory. The problem is that it doesn't match the paths, So, here my script and its output with the debug : #!/bin/bash # PATHS... (7 Replies)
Discussion started by: Arnaudh78
7 Replies

2. Shell Programming and Scripting

To print value for a $variable inside a $variable or file

Hi guys, I have a file "abc.dat" in below format: FILE_PATH||||$F_PATH TABLE_LIST||||a|b|c SYST_NM||||${SRC_SYST} Now I am trying to read the above file and want to print the value for above dollar variables F_PATH and SRC_SYST. The problem is it's reading the dollar variables as... (5 Replies)
Discussion started by: abcabc1103
5 Replies

3. Shell Programming and Scripting

Two question: remove from the other variable or file to get another variable or file

Question 1: A="a b c d e f g 1 2 3 4 5" B="c 3" get C="a b d e f g 1 2 4 5" Question 2: cat file1 a b c (6 Replies)
Discussion started by: yanglei_fage
6 Replies

4. Shell Programming and Scripting

problem in assigning value to variable have value fo other variable

my script is some thing like this i11="{1,2,3,4,5,6,7,8,9,10,11,}" echo "enter value" read value ..............suppose i11 x="$value" echo "$($value)" .............the echo should be {1,2,3,4,5,6,7,8,9,10,11,} but its showing "i11" only. plz help me out to get desired... (10 Replies)
Discussion started by: sagar_1986
10 Replies

5. Red Hat

How to pass value of pwd as variable in SED to replace variable in a script file

Hi all, Hereby wish to have your advise for below: Main concept is I intend to get current directory of my script file. This script file will be copied to /etc/init.d. A string in this copy will be replaced with current directory value. Below is original script file: ... (6 Replies)
Discussion started by: cielle
6 Replies

6. Shell Programming and Scripting

Problem with a variable withing a variable

hello there, basically im screwed with a variable that should take the last modification date of a file. my code is fileCreationTime=$(( `ls -l $fileName | tr -s " " | cut -d " " -f6` )) my problem arise coz when the code is executed and stored in a file the return value is 1993 and not... (4 Replies)
Discussion started by: thurft
4 Replies

7. Shell Programming and Scripting

Problem getting the content of a file in a shell script variable

Hi, I have a text file that has a long multi-line db2 CTE query. Now I want to store all the contents of this file (i.e. the entire query) in a shell script variable. I am trying to achieve it by this: query = `cat /Folder/SomeFile.txt` But when I echo the contents of this file by saying echo... (4 Replies)
Discussion started by: DushyantG
4 Replies

8. Shell Programming and Scripting

Split variable length and variable format CSV file

Dear all, I have basic knowledge of Unix script and her I am trying to process variable length and variable format CSV file. The file length will depend on the numbers of Earnings/Deductions/Direct Deposits. And The format will depend on whether it is Earnings/Deductions or Direct Deposits... (2 Replies)
Discussion started by: chechun
2 Replies

9. Shell Programming and Scripting

Records which are staring with double quote(") and a number

Hi Experts... I am trying to find out separting the records which are staring with double quote(") and a six digit number(ex: 012456,987654,etc) from a file. For example : Source File : "116462","SMITH CHEVR "164098","SIMPS "104498","SIMPSONVIL "Export lments" "Copyrts... (4 Replies)
Discussion started by: vsairam
4 Replies

10. Shell Programming and Scripting

Reading variable from file variable values

Hi, Here is the output of lpstat. I would like to read value of Queue which is(abxxxxb1)and status that is DOWN in first line. i dont care what is in second line. any one can help me.thanks Queue Dev Status Job Files User PP % Blks Cp Rnk ------- ----- ---------... (5 Replies)
Discussion started by: sagii
5 Replies
Login or Register to Ask a Question