Redirect the Time result to a test file


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Redirect the Time result to a test file
# 1  
Old 03-28-2006
Question Redirect the Time result to a test file

I need to store process runtime into a file, currently the command i use was:

time ls >> abc.txt

however, this command store the executed result of ls into the txt file but not the time command result.

Anyone know how to store the "time ls" result? Please advise me! Thanks in advance Smilie
# 2  
Old 03-28-2006
as per man pages time output is printed on stderr.

so this will do

time ls > abc.txt 2>tm.txt

abc.txt - op of ls command
tm.txt - op of time command
# 3  
Old 03-28-2006
try time -p ls 2>abc.txt

If this doesn't work, try with the full path of time command.. it works.
# 4  
Old 03-29-2006
doesn't work, the abc.txt is empty.

what mean by full path of time command? can have example?
# 5  
Old 03-29-2006
have you tried the following

Quote:
time ls > abc.txt 2>tm.txt

abc.txt - op of ls command
tm.txt - op of time command
# 6  
Old 03-29-2006
mistella, to get the path to a command, you can try running 'which <command>'. This will give you the path to the command. Like this:
Code:
# which time
/usr/bin/time

Also, vidhya has asked you to use the full path of the time command because the shell that you are using also has a builtin called time that will be executed instead of the time binary if you just run 'time'.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Hit multiple URL from a text file and store result in other test file

Hi, I have a problem where i have to hit multiple URL that are stored in a text file (input.txt) and save their output in different text file (output.txt) somewhat like : cat input.txt http://192.168.21.20:8080/PPUPS/international?NUmber=917875446856... (3 Replies)
Discussion started by: mukulverma2408
3 Replies

2. Shell Programming and Scripting

redirect time command output to file (cygwin bash)

I have set up a bash script to run a long list of things that I need to time. I would like to redirect the output of time to a file. I have set it up like, echo "Runtimes for servlet 4, 100K structures" > test_times.txt echo "" >> test_times.txt echo "runs where N=10" >> test_times.txt echo... (7 Replies)
Discussion started by: LMHmedchem
7 Replies

3. Shell Programming and Scripting

Redirect grep error/result to file

I'm having trouble piping grep results/error to a file. Why can't I redirect these messages into a file? $ grep -r -o "pattern" * > log Binary file foo1 matches Binary file foo2 matches Binary file foo3 matches Binary file foo4 matches The log is created, but remains empty. ... (1 Reply)
Discussion started by: chipperuga
1 Replies

4. Programming

Test program not giving expected result

I have five classes. 2 composition classes,1 aggregation class and 1 dependency class.I have coded all the classes but one of my test program is not giving me the expected result.I have the following classes: TimeStamp Interval (composition of 2 TimeStamps) TimeSheet ( aggregation of many... (3 Replies)
Discussion started by: moraks007
3 Replies

5. Shell Programming and Scripting

"Time" command and save result in a file.txt

Hi, I'am using "time" to check execution time of some script. Is there any possibility to save time command result into a file ? (2 Replies)
Discussion started by: Physix
2 Replies

6. Shell Programming and Scripting

How to redirect you o/p to many files at the same time.

How to redirect your o/p to many files without using for loop. For example:- 1-echo "blablabla" > out01 OUT 2-echo "blablabla" 1>out01 1>OUT 3-echo "blablabla" 1>&out01 1>&OUT the above code does not work! in "1" only the o/p goes to out01 in "2" & "3" the o/p goes to OUT ... (4 Replies)
Discussion started by: ahmad.diab
4 Replies

7. UNIX for Advanced & Expert Users

redirect to both file and std output at the same time

hello can some one please help me to redirect the output of a command to both std output and a file. this is little urgent. sridhar (2 Replies)
Discussion started by: send2sridhar
2 Replies

8. Shell Programming and Scripting

Real time log file redirect

Hi all, i would like to write the shell script program, it can monitor the access_log "real time" when the access_log writing the line contain "abcdef" the program will be "COPY" this line into a file named "abcdef.txt", do the same thing if the contain "123456" "COPY" it into a file named... (3 Replies)
Discussion started by: eric_wong_ch
3 Replies

9. UNIX for Dummies Questions & Answers

Redirect time output

Hello All, I am trying to write a script that would capture the output of time command on a Sun machine. I have tried these commands $ time ls > out $ time ls 2> out I just get the ls output in the out file for the first one. Thanks for any help Chuck (2 Replies)
Discussion started by: cbeech
2 Replies

10. UNIX for Dummies Questions & Answers

Display result one page at a time

hi how can i display the result on the screen one page at a time? say i search for .txt files and return the result on the screen one page at a time. (4 Replies)
Discussion started by: nickaren
4 Replies
Login or Register to Ask a Question