Reputation: 51
I wonder why this command:
FILE=`file /usr/bin/java | tr -d \`\' | awk '{print $5}'`
Results in this error message:
bash: command substitution: line 1: unexpected EOF while looking for matching ``'
bash: command substitution: line 2: syntax error: unexpected end of file
If I run the previous command without assigning it to a variable, it works as expected:
$ file /usr/bin/java | tr -d \`\' | awk '{print $5}'
/etc/alternatives/java
Does anyone know why this happens and how can I successfully assign the output value to a variable?
Note: for the curious, I'm trying to find the pointed path to a binary file from a symbolic link, so I can find out if it is a 32 or 64 bits file (in a generic way, not using something like java -version
)
Note 2: I've tried removing quotes with sed
instead of tr
, but it returns the same error
Thank you very much in advance, regards...
Nacho
Upvotes: 0
Views: 86
Reputation: 174696
I think it's because you enclosed the commands inside back-ticks. Use $()
instead of backticks.
FILE=$(file /usr/bin/java | tr -d \`\' | awk '{print $5}')
Upvotes: 5