1

say I have a set of commands like

touch /tmp/file.json
tool test --json |& tee /tmp/file.txt

firstchar=$(head -c 1 /tmp/file.txt)
ret=$?


#begin conditions.
if ((ret==0); then
##do something

instead of this: firstchar=$(head -c 1 /tmp/file.txt)

The statement $? is checking for the last command run firstchar instead of tool ...

How can I make the conditional statement check the status of this command: tool test --json |& tee /tmp/file.txt

Jshee
  • 2,620
  • 6
  • 44
  • 60

0 Answers0