I am going through a couple of BASH scripts. And I came across something like this
VAR_S=$(dd if=${MY_FILE} bs=16 count=1 skip=1024 iflag=skip_bytes 2>/dev/null | hexdump -e '16/1 "%02x"')
Apparently the Variable VAR_S should not be empty and I am trying to wrap my head around this statement. What does if=${MY_FILE}
mean here. I am trying to figure out why VAR_S is returning empty when I echo it.It seems to me like if
is a simple variable being assigned the value of MY_FILE
. In that case I dont understand the significance of assignment and why not just use dd ${MY_FILE}
Advertisement
Answer
See man dd
for explanation: if
stands for “input file”. These aren’t variable assignments, but parameters. Variable assignment can’t follow a command.