help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Help-bash] howto redirect time output to perl -pe "chomp;"?


From: Larry Evans
Subject: [Help-bash] howto redirect time output to perl -pe "chomp;"?
Date: Tue, 3 Jan 2017 10:07:21 -0600
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.5.1

I've read and reread:

https://www.gnu.org/software/bash/manual/bash.html#Appending-Standard-Output-and-Standard-Error
  https://www.gnu.org/software/bash/manual/bash.html#Pipelines
and tried every permuation I could think of:

--{--cut here--
address@hidden:~$ echo $SHELL
/bin/bash
address@hidden:~$ time 2>time.out

real    0m0.000s
user    0m0.000s
sys     0m0.000s
address@hidden:~$ cat time.out
address@hidden:~$ time > time.out

real    0m0.000s
user    0m0.000s
sys     0m0.000s
address@hidden:~$ cat time.out
address@hidden:~$ time 2> time.out

real    0m0.000s
user    0m0.000s
sys     0m0.000s
address@hidden:~$ cat time.out
address@hidden:~$ time |perl -pe "chomp"
bash: syntax error near unexpected token `|'
address@hidden:~$ time sleep 1|perl -pe "chomp"

real    0m1.003s
user    0m0.004s
sys     0m0.000s
address@hidden:~$ time sleep 1|&perl -pe "chomp">time.out

real    0m1.003s
user    0m0.000s
sys     0m0.004s
address@hidden:~$ cat time.out
address@hidden:~$ time sleep 1|& perl -pe "chomp">time.out

real    0m1.003s
user    0m0.004s
sys     0m0.000s
address@hidden:~$ cat time.out
address@hidden:~$ echo "hello" | perl -pe "chomp">time.out
address@hidden:~$ cat time.out
address@hidden:~$ echo "hello;" | perl -pe "chomp">time.out
address@hidden:~$ cat time.out
hello;address@hidden:~$ echo $SHELL
/bin/bash
address@hidden:~$ echo "hello" | perl -pe "chomp">time.out
address@hidden:~$ cat time.out
address@hidden sleep 2|& perl -pe "chomp">time.out

real    0m2.003s
user    0m0.004s
sys     0m0.000s
address@hidden:~$ cat time.out
address@hidden:~$ TIMEFORMAT='%3R';time sleep 1 &>| perl -pe "chomp"
bash: syntax error near unexpected token `|'
address@hidden:~$ TIMEFORMAT='%3R';time sleep 1 >| perl -pe "chomp"
sleep: invalid option -- 'p'
Try 'sleep --help' for more information.
0.001
address@hidden:~$ TIMEFORMAT='%3R';time sleep 1 | perl -pe "chomp"
1.001
address@hidden:~$ TIMEFORMAT='%3R';time sleep 1 | perl -pe "chomp" > time.out
1.003
address@hidden:~$ cat time.out
address@hidden:~$ TIMEFORMAT='%3R';time sleep 1 |& perl -pe "chomp" > time.out
1.002
address@hidden:~$ cat time.out
address@hidden:~$

--}--cut here--

Please, how do I get the output from time wittout the newline?

-regards,
Larry








reply via email to

[Prev in Thread] Current Thread [Next in Thread]