redirect cat to variable

hello
just i saw a really strange for cat

i have file (file1) contains line /home/rajiv/proj1/*.txt

now applied a commonds

DDPATH="$(cat file1)"
echo $DDPATH

it shows all the txt files in that folder like /home/rajiv/proj1/read1.txt /home/rajiv/proj1/read2.txt /home/rajiv/proj1/read3.txt ......

but i need only /home/rajiv/proj1/*.txt.
can anyone helps
shailesh

this works..

DDPATH=`cat file1`
echo "$DDPATH"

whatever you do just make sure you double quote your DDPATH variable when you print (or rather echo!)

cheers,
Hemanth

oops not working...
:frowning:

also i want to use this variable further in my script
BR
shailesh

What shell? Could you post the output that demonstrates expansion of the * with quoted variable?

It does work for me...

Here's the file output
bash-2.05b$ cat file1
/home/hemanth/*.txt

...and here are my commands...
bash-2.05b$ DDPATH=`cat file1`
bash-2.05b$ echo "$DDPATH"
/home/hemanth/*.txt

Send me your output so that I can check.

See the following example:

> cat file1
/home/jg/tmp/file_lookup/*.dat
> echo "$DDPATH"
/home/jg/tmp/file_lookup/*.dat
> echo $DDPATH
/home/jg/tmp/file_lookup/sample.dat
> echo /home/jg/tmp/file_lookup/*.dat
/home/jg/tmp/file_lookup/sample.dat
> 

So, try putting your variable with the echo inside quotes. echo "$DDPATH"

This is the same as typing the following:

>vi *.dat

Which would sequentially open for editing every .dat file you have.

yes if we do echo "$DPATH" it gives proper result. but when i want to use this variable for another use like as below -

for f in "$DPATH" `find -type f`;
do
processLine 
done

it give wrong result like it cant read file with *.mk in the folder.
BR
shailesh

It's not clear what you're trying to achieve with the above command, but if you need to generate filenames you should not quote the variable in that case.