[LINUX] substituting variable upon cat execution
Hi.
I have a file named "test.txt". It contains the following: Hello $USER1 Your boss is $ADMIN1 Now, I want to do something like this: export USER1="World" export ADMIN1="Me" cat test.txt > test2.txt And achieve something like this when I view the contents of test2.txt: Hello World Your boss is Me The problem is, it's not that easy to achieve. I don't want to do the "echo Hello $USER1 >> test2.txt" because I'm planning to implement this on a MB-sized text file. I can't google the right term that's why I explained it right away. ;) |
How many variables need to be replaced, That is the no of variable not the occurence ?
|
Hi,
this one worked with your sample code: Code:
while read LINE Hope this helps. |
and this one two:
Code:
awk '/\$/{ print | "echo "$0}' test.txt > test2.txt |
|
Quote:
|
All times are GMT -5. The time now is 12:14 AM. |