syntax error near unexpected token `&' (using "|&")

Viewed 19972

I have syntax error near unexpected token & in next : in bash scripts its'go like this :

#!/bin/bash
var1=`(/usr/bin/time cdifonline -CD 186821 -ALL > /dev/null)|& grep real|awk '{print $2}'`

when i issue this command on cli i get good output, problem is when invoke this in script i can get any output from var1

./check_cdifonline.sh: command substitution: line 2: syntax error near unexpected token `&'
./check_cdifonline.sh: command substitution: line 2: `(/usr/bin/time cdifonline -CD 186821 -ALL >/dev/null) | & grep real | awk '{print $2}''
3 Answers
Related