Time Utility


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Time Utility
# 1  
Old 12-06-2014
Time Utility

I am looking at some practice problems from a book involving the time utility and I am a little confused on what to do. Here is what it is telling me to do:

-Compile your sort:
gcc -o sort1 sort1.c quicksort.c
-For each input file, ins.n0000, get the time to execute:
time sort1 < file > /dev/null
-I would use the reported user time

This is what I did and got:

Code:
$ gcc -o sort1 sort1.c quicksort.c
$ time sort1 < sort1.c > /dev/null
No command 'sort1' found, did you mean:
 Command 'sort' from package 'coreutils' (main)
 Command 'sortm' from package 'nmh' (universe)
 Command 'sortm' from package 'mailutils-mh' (universe)
sort1: command not found

real    0m0.140s
user    0m0.100s
sys     0m0.028s
$ time sort1 < quicksort.c > /dev/null
No command 'sort1' found, did you mean:
 Command 'sort' from package 'coreutils' (main)
 Command 'sortm' from package 'nmh' (universe)
 Command 'sortm' from package 'mailutils-mh' (universe)
sort1: command not found

real    0m0.153s
user    0m0.112s
sys     0m0.028s

I have the two files and I am not sure what they mean by use the reported user time.
# 2  
Old 12-06-2014
Is . in your setting of $PATH?
If not, did you try:
Code:
$ time ./sort1 < sort1.c > /dev/null

This User Gave Thanks to Don Cragun For This Post:
# 3  
Old 12-06-2014
First, make sure sort1 is executable.

Then try $ time ./sort1 (full path to sort1)
Bash is not finding the new sort1 because it is not in your PATH.

Edit: Oops
Sorry Don Cragun. Didn't see your post in time.

Last edited by ongoto; 12-06-2014 at 11:05 PM.. Reason: posted too late...
This User Gave Thanks to ongoto For This Post:
# 4  
Old 12-06-2014
Thank you guys! It worked!
# 5  
Old 12-06-2014
Quote:
Originally Posted by totoro125
I am not sure what they mean by use the reported user time.
Quote:
Originally Posted by totoro125
Code:
real    0m0.140s
user    0m0.100s
sys     0m0.028s

# 6  
Old 12-07-2014
I am getting an error again, I trying to see how long it takes for different inputs so I compiled both.

Code:
$ gcc -o sort1 sort1.c quicksort.c
$ time sort1 < ins.n1000 > /dev/null
-bash: ins.n1000: No such file or directory

real    0m0.003s
user    0m0.000s
sys     0m0.000s
$ time ./sort1 < ./ins.n1000 > /dev/null
-bash: ./ins.n1000: No such file or directory

real    0m0.003s
user    0m0.000s
sys     0m0.000s

# 7  
Old 12-07-2014
If you want to know how long it will take to sort a file named ins.n1000, you actually have to have a file named ins.n1000 to sort.

To get rid of these error messages create a file named ins.n1000 in the directory where you are running sort1. Isn't this obvious from the bash diagnostics?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Red Hat

crypt utility

Hello all, I'm currently on HP-UX and will be moveing shortly to Red Hat Linux. Is there a crypt or an equivalent utitlity on RHEL? Thanks (4 Replies)
Discussion started by: luft
4 Replies

2. Shell Programming and Scripting

How to Unzip a file using unzip utility for files zipped without zip utility ?

Hi, I need to zip/compress a data file and send to a vendor. The vendor does have only unzip utility and can accept only .ZIP files. I do not have zip utility in my server. How do I zip/compress the file so that it can be deflated using unzip command ? I tried gzip & compress commands, but... (1 Reply)
Discussion started by: Sabari Nath S
1 Replies

3. Shell Programming and Scripting

utility

hi experts, Can you please help me out in removing delimiters with in double quotes from a CSV file. input: ===== a,"bnn,",dgd, "sagfh,dj",ad output ===== a,"bnn",dgd, "sagfhdj",ad there are so mnay fileds in a row and there are millions of rows. Thanks in an advance.... (6 Replies)
Discussion started by: subhendu81
6 Replies

4. Shell Programming and Scripting

Sed utility

I am new to unix os. Can you explain in short about sed? with some examples. (1 Reply)
Discussion started by: Padmav
1 Replies

5. UNIX for Dummies Questions & Answers

unknown utility

Hi everyone, I am a beginner in Linux and Shell scripting.I am migrating a couple of shell scripts from Solaris platform to Linux platform.In one script i saw a usage as : /base/article/ocilib/lobfile $username/$password $filename $filepath I didn't understand what this represents.The... (2 Replies)
Discussion started by: DILEEP410
2 Replies

6. UNIX Desktop Questions & Answers

Account Utility

Hi, I'm pretty new to UNIX and LINUX and am trying to find out what utility to use to manage accounts. Thanks for the help in advance. (3 Replies)
Discussion started by: klevr99
3 Replies

7. UNIX for Dummies Questions & Answers

Printing Utility

Hi I am looking for a printing utility option, which assist unix/linux administrator to control printing jobs. The major concerns are Assigning the particular printer and queue to a user profile Option to change the queue or printer for a particular printer job Option to change the printing... (2 Replies)
Discussion started by: mkhfsd
2 Replies

8. UNIX for Dummies Questions & Answers

Talk utility

Are "talk" sessions logged or can they be logged? (1 Reply)
Discussion started by: pbonilla
1 Replies

9. UNIX for Dummies Questions & Answers

useing date or other time style utility to get milliseconds.

hello everyone. im sure someone has run into the problem of timestamping files and end up haveing 2 files with the same name thus over writeing one of them. In my application i am trying to get a timestamp w/ milliseconds but i am haveing no luck and finding an answer in the man pages. I know... (3 Replies)
Discussion started by: Optimus_P
3 Replies

10. UNIX for Dummies Questions & Answers

What utility do I use for this?

I want to pull out the 3rd column of information and stick in a file. What is the Utility I use to do this? (8 Replies)
Discussion started by: James
8 Replies
Login or Register to Ask a Question