My aim is to log all output from a script into a directory that the script is going to create.
For example, I have:
~/.abc.sh:
#! /bin/bash
rails new myapp
When I run...
cd ~/code
. ~/.abc.sh
...that will create a new Rails app in directory ~/code/myapp.
When Rails is creating an app, it outputs a whole lot of text that I want to capture and store in a log file in the same directory the rails command newly created. I also want to display that text in the terminal as well.
How do I go about doing this?
~/.abc.sh | tee <file>? If so, then the trouble is I don't know in which directory the script is going to create the app when I call it, so how would I know what to give the in thefileargument? (Thanks for the great examples) – Zabba Apr 29 '11 at 18:19mktemp. See the manual pageman mktemp. – Lekensteyn Apr 29 '11 at 19:15command |& tee <file>. – thayne May 10 '23 at 22:54