Confused by command substitution and quoting

How do I assign output of a command to a variable without expanding it?

I have tried every combination of quoting I can think of including literal quotes in the command and user agent variable and still can't get it to work (or it breaks Lynx because Lynx tolorates spaces in the useragent but expands it if quoted!)

agent="Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Firefox/31.0"
dump=$( lynx -useragent="$agent" -dump "$site" )

Mike

How do you know it does not work? If you are printing the content of the variable dump that also needs to be quoted:

echo "$dump"
1 Like

I compulsively quoute variable for just this reason in real code but got lazy in my debug code.

Thanks. I wish there was a smilie for kicking oneself . . .

Mike