Quantcast
Channel: UNIX and Linux Forums
Viewing all articles
Browse latest Browse all 16232

awk in shellscript

$
0
0
Dear Members,

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:
Code:

cat /tmp/file | awk -F '"fields":' '{print $2}' | awk -F '"description":' '{print $4}' | awk -F ',' '{print $1}' | awk -F '"' '{print $1}'
This works fine and give me the information I need:
Code:

My Information
Now pasting the same command in a shell variable
Code:

content=`cat /tmp/file | awk -F '"fields":' '{print $2}' | awk -F '"description":' '{print $4}' | awk -F ',' '{print $1}' | awk -F '"' '{print $1}'`
suddenly gives me all files and folders in that directory followed by the information I'm looking for:
Code:

folder1 folder2 file1 file2 My Information
Does anyone have a clue what could cause such behavior and can give some advice on how to get rid of the file information?

Thank you very much in advance
Crumble

Viewing all articles
Browse latest Browse all 16232

Latest Images

Trending Articles



Latest Images