I was attempting to run a script in bash: cc.sh
To run the bash script:
../cc.sh ../seq/ seqf
where ../seq/ and seqf are both arguments required.
I wanted to save the command I used to run the script (the command above), together with the output/result from the script into a log file.
I managed to print the output into a log file with tee command.
../cc.sh ../seq/ seqf 2<&1 | tee -a cc.log
cat cc.log:
"here is where the output shown"
While for the command itself, the closest I got is the script command. However, it seemed to save the command I used to run in a binary file.
Is there other better way to print the command other than script? Or better, print the command used to run the script file, together with the output/result into a log file?
Expected output for the log file:
COMMAND: ../cc.sh ../seq/ seqf
"here is where the output shown"
scriptsaves the output exactly as it is sent to your terminal. That means that fancy prompts and carriage returns show up as escape sequences. "Certain interactive commands, such as vi(1), create garbage in the typescript file. script works best with commands that do not manipulate the screen, the results are meant to emulate a hardcopy terminal." - from the man page.