|
|||||||
| Forums | Search Forums | Register | Forum Rules | Man Pages | Albums | FAQ | Members | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
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 |
| Sponsored Links | ||
|
|
#2
|
|||
|
|||
|
Redirecting cat
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 |
| Sponsored Links | ||
|
|
#3
|
|||
|
|||
|
cat
oops not working...
![]() also i want to use this variable further in my script BR shailesh |
|
#4
|
||||
|
||||
|
What shell? Could you post the output that demonstrates expansion of the * with quoted variable?
|
| Sponsored Links | |
|
|
#5
|
|||
|
|||
|
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. |
| Sponsored Links | |
|
|
#6
|
||||
|
||||
|
See the following example: Code:
> 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: Code:
>vi *.dat Which would sequentially open for editing every .dat file you have. |
| Sponsored Links | |
|
|
#7
|
|||
|
|||
|
cat
yes if we do echo "$DPATH" it gives proper result. but when i want to use this variable for another use like as below - Code:
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 Last edited by radoulov; 07-10-2008 at 04:35 AM.. Reason: please use code tags |
| Sponsored Links | ||
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| redirect frintf to a variable | robo | Shell Programming and Scripting | 8 | 09-27-2011 07:32 PM |
| Redirect to a Variable? Or is it cmd cap? | oxoxo | UNIX for Dummies Questions & Answers | 2 | 11-22-2008 07:59 AM |
| after grep i want to redirect it to some variable | mail2sant | Shell Programming and Scripting | 2 | 04-07-2008 09:26 AM |
| Redirect to variable | MrAd | UNIX for Dummies Questions & Answers | 2 | 05-07-2007 04:18 PM |
| please help: how to redirect input into a variable | artur80 | Shell Programming and Scripting | 2 | 11-17-2002 09:18 AM |
|
|