3

I'm using Ubuntu 23.10 x64. The time program has an -f flag but when I run it says -f command not found.

time -f "%Uu %Ss %er %MkB %C" ./countwords hamlet.txt

I'm trying to get the time program to output the memory use in addition to the default output.

terdon
  • 242,166
Leahcim
  • 289

1 Answers1

6

You're probably running bash (or zsh), which has its own time command built-in so that it can time a whole pipeline and not just a single command:

type time
  time is a shell keyword

help time time: time [-p] pipeline Report time consumed by pipeline's execution. […]

You can see that the built-in time command has only an optional -p flag.

If you want to use the external time command (/usr/bin/time) as shown in man time you will need to specify it explicitly:

command time -f '%Uu %Ss %er %MkB %C' ./countwords hamlet.txt
ilkkachu
  • 138,973
Chris Davies
  • 116,213
  • 16
  • 160
  • 287