Grep time command output

后端 未结 5 1076
长情又很酷
长情又很酷 2021-02-02 06:38

Using time ls, I have the following output:

$ time ls -l 
total 2
-rwx------+ 1 FRIENDS None 97 Jun 23 08:59 location.txt
-rw-r--r--+ 1 FRIENDS None         


        
5条回答
  •  离开以前
    2021-02-02 07:42

    If you just want to specify the output format of time builtin, you can modify the value of TIMEFORMAT environment variable instead of filtering it with grep.

    In you case,

    TIMEFORMAT=%R
    time ls -l
    

    would give you the "real" time only.

    Here's the link to relevant information in Bash manual (under "TIMEFORMAT").

    This is a similar question on SO about parsing the output of time.

提交回复
热议问题