1758329 Members
2021 Online
108868 Solutions
New Discussion юеВ

time in ksh

 
SOLVED
Go to solution
Jannik
Honored Contributor

time in ksh

in a ksh (shell) i want to only have one line output of this command:
time ls | grep real | awk '{print $2}
this is the output:
real 0.01
user 0.00
sys 0.00
this is what i want:
0.01

I know that is something to do with standard error.
jaton
7 REPLIES 7
Massimo Bianchi
Honored Contributor

Re: time in ksh

time ls 2>&1 | grep real | awk '{print $2}

Massimo
RAC_1
Honored Contributor

Re: time in ksh

Seems that you can do this. Some inbuilt format structure with time command.
There is no substitute to HARDWORK
Massimo Bianchi
Honored Contributor

Re: time in ksh

better:
time ls 2>&1 | awk '/real/ {print $2}'

Massimo
Jannik
Honored Contributor

Re: time in ksh

root@fox[ / ]#ksh
root@fox[ / ]#time ls 2>&1 | awk '/real/ {print $2}'

real 0m0.02s
user 0m0.01s
sys 0m0.01s

It still doesn't work
jaton
RAC_1
Honored Contributor

Re: time in ksh

Seems that you can not do this. Some inbuilt format structure with time command.

Tried tr also. Seems in built in time/timex.
There is no substitute to HARDWORK
Massimo Bianchi
Honored Contributor
Solution

Re: time in ksh

(time ls) 2>&1 | awk '/real/ {print $2}'



you were right, sorry !
now it works under ksh

Massimo
RAC_1
Honored Contributor

Re: time in ksh

Massimo Bianchi solution works.

Not an expert with awk.



There is no substitute to HARDWORK