4 ms·
On bash you can do this to have it not use an alias or built-in command: $ \time echo 0.00user 0.00system 0:00.00elapsed 100%CPU (0avgtext+0avgdata 1764ma
by graton 10y ago
On bash you can do this to have it not use an alias or built-in command:
$ \time echo
0.00user 0.00system 0:00.00elapsed 100%CPU (0avgtext+0avgdata 1764maxresident)k
0inputs+0outputs (0major+66minor)pagefaults 0swaps
The built-in version:
$ time echo
real 0m0.000s
user 0m0.000s
sys 0m0.000s
- yrro 10y agoIs this behaviour documented anywhere? The closest I can find is https://www.gnu.org/software/bash/manual/bashref.html#Aliases https://www.gnu.org/software/bash/manual/bashref.html#Aliase... which remarks, > The first word of each simple command, if unquoted, is checked to see if it has an alias. I observe that t\ime works just as well as \time.
- ptx 10y agoJust quoting it normally also works, apparently, as your excerpt from the man page suggests: $ help|head -1 GNU bash, version 4.3.30(1)-release (x86_64-pc-linux-gnu) $ "time" --version GNU time 1.7 $ time --version bash: --version: command not found real 0m0.001s user 0m0.000s sys 0m0.000s
- sigjuice 10y agot\ime is rather surprising. Is there any documentation or explanation on why it does what it does?
- yrro 10y agohttps://www.gnu.org/software/bash/manual/bashref.html#Escape-Character https://www.gnu.org/software/bash/manual/bashref.html#Escape... I think it's because using the backslash to escape counts as quoting. So the following are all equivalent: $ \time foo $ t\ime foo $ 'time' foo
- bobbyi_settv 10y agoThe conventional way of forcing bash not to use a built-in is by using the full path (/usr/bin/time in this case).
- eridius 10y agoThe more obvious way of doing this is command time echo The usage of the `command` keyword makes it ignore shell functions (including built-in shell keywords like time).