I am trying to read the output of background process as
pwd &
and want to read it line by line (or store in a file). I tried to store the output in a file using > and tee but it didn't worked.
[anuj@localhost ~]$ ls & | tee output.txt
bash: syntax error near unexpected token `|'
[anuj@localhost ~]$
[anuj@localhost ~]$ ls & > output.txt
using > it is executing the command but nothing storing in the output.txt
FYI,
Basically I want to execute multiple command from a .sh file but after every command's execution I want to check the output of that command (before going to next command) to decide to move next command or abort the script.
output of that command (before going to next command)read certain string from previous command (or) if the command runs successfully, run the next command?