How to evaluate the value read from a file?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to evaluate the value read from a file?
# 1  
Old 07-21-2008
Question How to evaluate the value read from a file?

Hi,

Could someone please help me with how to do the following?

Say I have a flat file test.lst and the content of the file is:
Report Date - `date '+%m%d%Y'`

I'm trying the following

while read myLine
do
echo ${myLine}
done<test.lst

This prints Report Date - `date '+%m%d%Y'`. I want the output as follows Report Date - 07212008. How can i accomplish this? Would eval print work?

regards,
Arun.
# 2  
Old 07-21-2008
Never mind guys... Figured out how to do this...

eval echo ${myLine} does the job for me...

regards,
Arun.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Evaluate Variable At Runtime

Hi, I am trying to set a variable that has time the format desired. And my intention is to echo variable (instead of actual date command) everytime I like to echo date. Please take a look at below code. $NOW='' echo $NOW After 5 minutes $echo $NOW Issue here is , I am not... (2 Replies)
Discussion started by: vinay4889
2 Replies

2. Shell Programming and Scripting

Copy file and evaluate its internal variables

Hi I have been trying to figure a way to copy a file, (a template), that has internal variables. Using the values as defined for those variables in another script. So a file called x - #! /bin/bash D=aa.$X.bb And file y #! /bin/bash X=6 while read line do eval echo... (5 Replies)
Discussion started by: steadyonabix
5 Replies

3. UNIX for Dummies Questions & Answers

How does ||: evaluate?

In BASH, how does ||: get interpreted. I know || is logical or. And I believe : evaluates to true. Can someone give a thorough explanation for this usage? Example for i in $IGGY do && skipdb=1 || : (6 Replies)
Discussion started by: glev2005
6 Replies

4. Shell Programming and Scripting

How to evaluate expressions in file

I have a situation where i need to evaluate expression and do substitutions in file file.ports port1=`expr $STARTINGPORT + 1` port2=`expr $STARTINGPORT + 2` port3=`expr $STARTINGPORT + 3` Intended output If my STARINGPORT is 100 port1=101 port2=102 port3=103 Can anyone please... (1 Reply)
Discussion started by: sasiharitha
1 Replies

5. UNIX for Dummies Questions & Answers

Read a flat file, evaluate and create output. UNIX SCRIPT.

Hi all, I have a flat file as below; 470423495|1||TSA-A000073800||1|||1 471423495|1||TSA-A000073800||5|||5 472423495|1||TSA-A000073800||2|||7 473423495|1||TSA-A000073800||3|||3 I like to create a Unix script. The script have to valuate the last two columns, if the values are... (4 Replies)
Discussion started by: mrreds
4 Replies

6. UNIX for Dummies Questions & Answers

When reading a csv file, counter to read 20 lines and wait for minute then read next 20 till end

Hello All, i am a newbie and need some help when reading a csv file in a bourne shell script. I want to read 10 lines, then wait for a minute and then do a reading of another 10 lines and so on in the same way. I want to do this till the end of file. Any inputs are appreciated ... (3 Replies)
Discussion started by: victor.s
3 Replies

7. Shell Programming and Scripting

How to evaluate the value of a variable ?

How to evaluate the value of a variable ? For example: a=var $a=value !!!error happens!!! I want to evaluate var=value, how to realize it? Thanks! ---------- Post updated at 03:37 AM ---------- Previous update was at 02:22 AM ---------- I am using linux bash. a=var $a=value... (4 Replies)
Discussion started by: 915086731
4 Replies

8. Programming

Cannot read a file with read(fd, buffer, buffersize) function

# include <stdio.h> # include <fcntl.h> # include <stdlib.h> # include <sys/stat.h> int main(int argc, char *argv) { int fRead, fPadded, padVal; int btRead; int BUFFSIZE = 512; char buff; if (argc != 4) { printf ("Please provide all of the... (3 Replies)
Discussion started by: naranja18she
3 Replies

9. Shell Programming and Scripting

Evaluate the value of a variable?

I have variables: FOO="Text" BAR="FOO" I'd like to be able to evaluate the variable named as the value of $BAR. echo $FOO Text echo $BAR FOO This is what I'd like to do: echo ${$BAR} (this won't work) Text (3 Replies)
Discussion started by: Ilja
3 Replies

10. Shell Programming and Scripting

how to get variable to re-evaluate itself?

Probably a simple one. Basically I am retrieving a number from a file - setting a variable against it and then incrementing this by 1 and using this as an entry number in a log file for messages. I need the variable to re-evalute itself each time I call it so I get the latest number in the file -... (1 Reply)
Discussion started by: frustrated1
1 Replies
Login or Register to Ask a Question