Skip to content

Repository files navigation

bash_builtin_file_utils

Summary

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

Installation

First Install dependencies

Compile:

compile_C.sh  bashbuiltin_file_utils.c

Usage

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

Related

  • 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.

About

Bash extensions related to files to avoid external programs like /usr/bin/stat

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages