For obtaining file attributes like the last-modified-time or the file-size in Bash scripts the UNIX tool /usr/bin/stat is usually used. This takes a few milliseconds because /usr/bin/stat is an external program. This builtin provides a bunch of commands to fetch file informantion much faster.
Status: Working
First Install dependencies
Compile:
compile_C.sh bashbuiltin_file_utils.c
The compiled builtins must be loaded once. The compile script generates a script which can be sourced.
source load_this_builtin.sh
This file contains the list of commands. To obtain help for the builtin commands type for example
help cg_fileSize
-
Standar bash plugin finfo: This allows to obtain e.g. the file size with bash lines like size=$(finfo -s file). As this plugin cannot be used without fork(), there is still a large overhead.
-
The standard plugin stat is very fast as it it does not require fork(). The result is captured in an hashmap. However, it is less convenient as finfo.