Redirecting output to file

Hi,

Below is the whole string which is to be redirected to the new file.

su - oracle -c "exp $user/$pass file=/oracle/oradata/backup/exp_trn_tables_`date +%d_%b_20%y_%H_%M_%S`.dmp log=/oracle/oradata/backup/exp_trn_tables_`date +%d_%b_20%y_%H_%M_%S`.log tables=table1,table2 statistics=none"

How to redirect the string to /tmp/exp_file.sh exactly as mentioned above using echo command ?

With Regards

echo 'su - oracle -c "exp $user/$pass file=/oracle/oradata/backup/exp_trn_tables_`date +%d_%b_20%y_%H_%M_%S`.dmp log=/oracle/oradata/backup/exp_trn_tables_`date +%d_%b_20%y_%H_%M_%S`.log tables=table1,table2 statistics=none"' >/tmp/exp_file.sh

just enclosed in simple quote echo 'cmd' > your file

the only char that have a meaning in simple quote is simple quote itself
value between them will not get interpreted unless you use the eval command

Since your string doesn't have any simple quote, we can just enclose it ans pass it as is in a file of your choice

1 Like

Have you tried to use tee?, maybe if you want to execute the command and redirect the output to another file.

Also maybe you can use script.

Hi,

Thanks.

With Regards