problem with $HOME and awk
Hi,
Suprinsingly the two codes differs in output :( (??) echo '$HOME/fileb.txt' > "$HOME/file.ini" Code:
head -n 1 "$HOME/file.ini" | awk -v vk="$HOME" ' { gsub("\$HOME",vk) ; print $0 } ' Code:
|
Well as you included no input or output, it will be difficult to test / see the difference?
I would however urge you to use $() over `` when issuing more complex substitutions. |
Quote:
with $() it returns /home/peterba/file.ini why so big difference? why is it like that? |
You still have not indicated what is in file.ini, or at least what the first line might actually be.
Currently the code looks pointless without anymore information. Maybe you could actually advise what it is you are trying to achieve? |
the problem is the quote evaluation, in the second case there is one more level of quotes (backtick) which will modify how the "program" will be seen during execution.
|
Quote:
Why is $(...) preferred over `...` (backticks)? http://mywiki.wooledge.org/BashFAQ/082 Quote:
Code:
echo "`echo "\$HOME"`" |
What does awk return?
|
All times are GMT -5. The time now is 02:10 PM. |