I have the following situation I do not understand:
I have a large json encoded file which I need to grep and afterwards want to extract specific information.
I use this command to to that:
I was able to cut the problem to a minimal example:
Let's have a file /tmp/file with
"* My Information"
Now,
cat /tmp/file | awk -F '"' '{print $2}'
gives the expected result:
* My Information
Yet,
content=`cat /tmp/file | awk -F '"' '{print $2}'`
gives
file1 file2 My Information
The problem is the asterisk (*). If the asterisk is not present, it does not get substituted with the files and directories.
I assume I have to escape those characters but I cannot find a table of characters which have to be escaped. Maybe there is another way using other quote types or something else.
Any further help is very much appreciated!
I suspect it's just the way you're displaying $content.
echo * will be globbed by the shell before it display anything (which results in the list of filenames). Double-quotes should fix it (i.e. echo "${var}" ).