Directing program output to a file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Directing program output to a file
# 1  
Old 06-11-2008
Directing program output to a file

When I do

Code:
time tar cvf /dev/st0 /mnt/junk >> /root/benchlog

, I want it to put the output of the time command into the benchlog file, but it put /mnt/junk. How do I get it to put the output of the tar command?

Last edited by jeriryan87; 06-11-2008 at 04:26 PM..
# 2  
Old 06-11-2008
Quote:
Originally Posted by jeriryan87
When I do

Code:
time tar cvf /dev/st0 /mnt/junk >> /root/benchlog

, I want it to put the output of the time command into the benchlog file, but it put /mnt/junk. How do I get it to put the output of the tar command?
Code:
/bin/time tar cvf /dev/st0 /mnt/junk 2>> /root/benchlog

time may be a shell builtin so I give it the exact pathname. If you want to use a shell builtin (eg, you are using bash), do:

Code:
{ /bin/time tar cvf /dev/st0 /mnt/junk; } 2>> /root/benchlog

-mschwage
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Run a program-print parameters to output file-replace op file contents with max 4th col

Hi Friends, This is the only solution to my task. So, any help is highly appreciated. I have a file cat input1.bed chr1 100 200 abc chr1 120 300 def chr1 145 226 ghi chr2 567 600 unix Now, I have another file by name input2.bed (This file is a binary file not readable by the... (7 Replies)
Discussion started by: jacobs.smith
7 Replies

2. UNIX Desktop Questions & Answers

Re-directing output

ps –xyz >/tmp/proc 2>&1 Can anyone explain what does '2' and '&1' will do here? Thanks to explain (1 Reply)
Discussion started by: kkalyan
1 Replies

3. Shell Programming and Scripting

Directing only part of a script's output to piped application

Is there a way to keep the output of a script displayed on the terminal when it's run by itself, but suspend part of that output and only have a specific part delivered when it's piped to another script or program? I'm thinking something like the following pseudocode: #!/bin/bash ... (1 Reply)
Discussion started by: trigg
1 Replies

4. Shell Programming and Scripting

Help me! Format output file using shell program

Hi, I have following input file. I want to generate output file in specific format using shell program. The input file has atleast few thousands of lines, the below are some sample lines. Input file: "ORDER NO"|"ORDER AMT"|"LINE ITEM"|"LINE AMT"|"SALES COMMISION %" ORD3456|5000|LIN345|30|25%... (8 Replies)
Discussion started by: dsubha
8 Replies

5. Shell Programming and Scripting

Way to save output result of a program into another new file...

Does anybody know any alternative way to save output result of a program into another new file? I got try the command below: program_used input_file > new_output_file program_used input_file >> new_output_file Unfortunately, both the ">" and ">>" is not work at this case to save the output... (6 Replies)
Discussion started by: patrick87
6 Replies

6. Shell Programming and Scripting

Directing awk output to a folder

Dear All I have a simple bash script that creates a folder ( I called it TEMP) in the current directory. The question is: how do I direct the output of my awk script into folder TEMP? Below is my attempt: #!/bin/bash mkdir TEMP echo Enter input file: read infile awk... (4 Replies)
Discussion started by: Ghetz
4 Replies

7. Shell Programming and Scripting

directing output to multiple files

I have a script in which some outputs are directed to one file echo "Load Started" >>${LOGFILE1} If I have another file LOGFILE2 and i want to redirect the output of the above echo command to LOGFILE2 as well with the same command line... how can i do that? Thanks (2 Replies)
Discussion started by: cobroraj
2 Replies

8. Shell Programming and Scripting

get output of program within a script to a file

I am running a program which probably calla script within, this script executes in a pop window and control returns back to main program. Whilw this script is executing i can see a number of messages being displayed but I cannot read them ,too fast. Is their a way I can redirect those... (3 Replies)
Discussion started by: ruchimca
3 Replies

9. Programming

Regardign strtok() output directing to 2-D string array

Hi, I just wrote a program in C to split a comma seperated string in to group of strings using strtok() function. The code is: int main() { char *temp;//not used here but basically we extract one string after another using strtok() and assign to a string pointer defined like this. ... (3 Replies)
Discussion started by: SankarV
3 Replies

10. UNIX for Dummies Questions & Answers

directing output

How do I direct the output of an at command at now < backupprogram so that I see something happening. It says the job has been executed but I am not getting the tar file that my backup program on the computer anywhere at all Please help me - I really am a struggling begginer. (1 Reply)
Discussion started by: Cynergetix
1 Replies
Login or Register to Ask a Question