On Wed, Oct 23, 2013 at 4:10 PM, Raja Mahalingam <[email protected]>wrote:

> Hi all,
>
> I need to know how to redirect the o/p of the script both to stdout and to
> file.
>
> I need to run the script from job scheduler,so I cant use pipes or tee
> command from the command line.so the redirection need to be coded in the
> script itself.
>
>
What about the below example?

$ ls
demo.sh  samplefile1.txt  samplefile2.txt  samplefile3.txt

$ cat demo.sh
#!/bin/bash
/bin/ls

$ ./demo.sh 2>&1 | tee  demo_output.txt
demo_output.txt
demo.sh
samplefile1.txt
samplefile2.txt
samplefile3.txt

$ cat demo_output.txt
demo_output.txt
demo.sh
samplefile1.txt
samplefile2.txt
samplefile3.txt


Thanks
Mohan L
_______________________________________________
ILUGC Mailing List:
http://www.ae.iitm.ac.in/mailman/listinfo/ilugc
ILUGC Mailing List Guidelines:
http://ilugc.in/mailinglist-guidelines

Reply via email to