help-bash
[Top][All Lists]
Advanced

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

[Help-bash] Howto get tags into TIMEFORMAT? (was Re: howto redirect time


From: Larry Evans
Subject: [Help-bash] Howto get tags into TIMEFORMAT? (was Re: howto redirect time output to perl -pe "chomp; "?
Date: Tue, 3 Jan 2017 14:09:58 -0600
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.5.1

On 01/03/2017 10:21 AM, Greg Wooledge wrote:
How can I redirect the output of 'time' to a variable or file?

http://mywiki.wooledge.org/BashFAQ/032


Thanks again; however, now I can't get tabs in the TIMEFORMAT.
Searching in:

https://www.gnu.org/software/bash/manual/bash.html#Bash-Variables

for TIMEFORMAT lead to the following:

If this variable is not set, Bash acts as if it had the value

$'\nreal\t%3lR\nuser\t%3lU\nsys\t%3lS'

So, I figured I could use:

  TIMEFORMAT='\nreal\t%1R'

However, when I did, with the following gmake target:

SHELL:=/bin/bash
#^to enable use of TIMEFORMAT below.
.ONESHELL:
STRIP_NL:=perl -pe "chomp;"

time:
        echo -n "address@hidden">time.out
        TIMEFORMAT='\nreal\t%1R'
        { time sleep .22222 ; } 2>&1 | $(STRIP_NL) >>time.out
        echo "}$@">>time.out
show:time
        @echo "+++$@:"
        @cat time.out
        @echo "---$@:"

I got this:

make -f time.mk show
echo -n "time{">time.out
TIMEFORMAT='\nreal\t%1R'
{ time sleep .22222 ; } 2>&1 | perl -pe "chomp;" >>time.out
echo "}time">>time.out
+++show:
time{\nreal\t0.2}time
---show:

Compilation finished at Tue Jan  3 14:03:13

How do I get tabs into the output?

TIA.

-regards,
Larry





reply via email to

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