Hi,
Is there any command in unix similar to spool command in oracle.
Hi,
Is there any command in unix similar to spool command in oracle.
If you consider SPOOL command causes SQL*Plus to write the results to a file.
SQL> spool /tmp/output.lst
In UNIX send the result (output) of ls to a file would be
$ ls >/tmp/output.txt
But I wonder if you are not thinking of something else like script
do a man of script command and see if thats not your answer
vbe,
ls >/tmp/output.txt
man ls >/tmp/output.txt
from the above line 1, it will redirect the ls o/p to the file /tmp/output.txt.
second line also do the same as redirect the o/p to the file /tmp/output.txt.
for each time i need to provide the redirection to file.
whereas in Oracle, Spool command will write the results to a file untill i provide spool off.
is there any command equalient to spool in unix ???
No.
You can do:
./script >file 2>&1
Yes. Use redirection. At the top of your script, put:
exec 1>/tmp/output.txt
Thanx,
As per suggestion its working fine but it re-directing everthing to a file. i need to display the results also in the screen.
For eg: File.sh
exec 1>/tmp/output.txt
ls -ltr
exit
when i run this script, its redirect to a file /tmp/output.txt but it not displaying in the screen. what needs to do ?
I had found the answer for this. there is an command called script in unix which will make record of a terminal session (like spool does in oracle). to stop the spooling type exit.