I have a small workflow formed by one run.sh script that automates a few scripts.
In this run.sh I have a function to run some INFO and ERROR messages and save it in a log.txt file but the scripts also generate outputs. I would like to save these outputs in another log file and also see the output when I run the pipeline.
I run my pipeline with this command.
run.sh -f1 a file -f2 other file -d a/directory.
I have seen I can do that as explained in this link
But as long as I know this will not show me the output in the terminal.
How can I get output in the terminal and also save it in a file? I am using a cluster computer and the output in the terminal is not saved if I lost the conection or log off from my PC.
CodePudding user response:
You know about tee? Something like...
run.sh -f1 a file -f2 other file -d a/directory | tee output.txt
...would run your script and show the standard output, while at the same time store it in output.txt
CodePudding user response:
Put you result into a file then show the file content in live with linux tail command like this code
#!/bin/bash
ls > result.txt
tail -f 100 ls.txt
