?
Solved

Bash variable inside another varaible

Posted on 2010-09-20
2
Medium Priority
?
198 Views
Last Modified: 2013-12-26
Looking to find out how to place a variable inside a variable.  The situation is this.  Every month a vulnerability scan is done using nessus and then exported to csv and I have a script to parse and clean out the know exceptions from the csv file.

Here is the initial script:

#### Variables
## Original Files
ORIG_FILE=File_090110_vulndata.csv
## Cleansed Files
NEW_FILE_CLEANSED=File_090110_vulndata_cleansed.csv
## Exceptions Files
NEW_FILE_EXCEPT=File_090110_vulndata_exceptions.csv

egrep -v "^.(40802|40803|40804|40805|42119|43875|44643|4550|44060|18405)" $ORIG_FILE > $NEW_FILE_CLEANSED

egrep "^.(Id|40802|40803|40804|40805|42119|43875|44643|4550|44060|18405)" $ORIG_FILE > $NEW_FILE_EXCEPT

Open in new window


Now what I am trying to do is include a variable which would include the date and use this new variable inside the file name so that every month one would just have to change the date in one spot.  Using this example the script would look like this:

#### Variables
MDATE=090110
## Original Files
ORIG_FILE=File_$MDATE_vulndata.csv
## Cleansed Files
NEW_FILE_CLEANSED=File_$MDATE_vulndata_cleansed.csv
## Exceptions Files
NEW_FILE_EXCEPT=File_$MDATE_vulndata_exceptions.csv

egrep -v "^.(40802|40803|40804|40805|42119|43875|44643|4550|44060|18405)" $ORIG_FILE > $NEW_FILE_CLEANSED

egrep "^.(Id|40802|40803|40804|40805|42119|43875|44643|4550|44060|18405)" $ORIG_FILE > $NEW_FILE_EXCEPT

Open in new window


However, this above code does not work and is the reason I am looking for assistance.
0
Comment
Question by:melod
2 Comments
 
LVL 48

Accepted Solution

by:
Tintin earned 2000 total points
ID: 33721678
Just needs braces

ORIG_FILE=File_${MDATE}_vulndata.csv
0
 

Author Comment

by:melod
ID: 33721748
LOL... thanks I tried everything but braces....  Glad you picked it up so fast.  Easy points for you. Thank you!
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This Windows batch file is useful for organizing image files from a digital camera or other source, but can have many other uses.  It simply renames the file(s) to match their create date.  For example, if you took a picture today at 1:40pm and the …
Recently, an awarded photographer, Selina De Maeyer (http://www.selinademaeyer.com/), completed a photo shoot of a beautiful event (http://www.sintjacobantwerpen.be/verslag-en-fotoreportage-van-de-sacramentsprocessie-door-antwerpen#thumbnails) in An…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
Suggested Courses

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question