1
0
Fork
You've already forked awkl
0
📚 Standard modules for gawk
  • Awk 97.4%
  • M4 1.9%
  • Makefile 0.4%
  • Shell 0.3%
2025年07月14日 08:28:57 +00:00
bin refactor(type)!: change to shorter naming. isNumeric to isNumbery and isNumerical to isNumeric 2025年06月23日 19:50:47 +00:00
docs docs(style): reduce sidebar width 2025年03月21日 00:51:23 +00:00
examples docs(api+bench): add basic example file for benchmarking 2025年06月23日 19:50:47 +00:00
m4 docs(api+m4+str): add documentation commments for str module 2025年07月14日 08:20:02 +00:00
packaging build(packaging): add lure-git for building on linux 2025年01月13日 20:26:46 +00:00
src docs(api+str): update documentation comments for str module 2025年07月14日 08:28:57 +00:00
submodules docs(style): add submodule for documentation style 2025年03月20日 08:59:40 +00:00
test refactor(type)!: change to shorter naming. isNumeric to isNumbery and isNumerical to isNumeric 2025年06月23日 19:50:47 +00:00
.gitignore docs(style): add custom style for doxygen documentation and configuration 2025年03月21日 00:51:23 +00:00
.gitmodules docs(style): add submodule for documentation style 2025年03月20日 08:59:40 +00:00
configure.ac build: add autotools build system configuration 2025年01月13日 20:26:46 +00:00
Doxyfile docs(build): add example path 2025年06月23日 18:56:26 +00:00
LICENSE chore(license): add license and notes 2025年01月13日 19:40:13 +00:00
LICENSE_notes chore(license): add license and notes 2025年01月13日 19:40:13 +00:00
Makefile.am build: fix documentation make targets 2025年06月24日 20:10:46 +00:00
README.md docs(readme): add path module link 2025年06月29日 22:39:38 +00:00

Awkl

Awk's well-kempt library

Table of Contents

📰 Description

Awkl (short for Awk's well-kempt library) is a library that attempts to bring modules present in other languages' standard libraries to gawk

The library makes use of gawk's namespaces (available since version 5.0) and other gawk-specific features, but we reckon a good part of the library could be adapted to be awk-agnostic (maybe with a hypothetical transpiler)

📦 Modules

  • math: Math-related functions
  • str: String-related functions
  • arr: Array-related functions
  • stats: Statistics-related functions
  • rnd: Randomness-related functions
  • path: Filesystem paths-related functions
  • type: Type-related functions
  • time: Timing-related functions
  • cmd: System commands related functions
  • opt: Command-line argument parser
  • bit: Functions for bit manipulation
  • color: Functions for coloring text in Xterm terminals
  • set: Functions for sets
  • parseutils: Functions to help parsing strings
  • test: Unit tester
  • bench: Benchmarker

📟 Usage

Ensure your AWKPATH includes the /usr/share/awk path (or ~/.local/share/awk in case of user-installation):

export AWKPATH="$AWKPATH:/usr/share/awk"

And now you can include the modules:

  • On the command-line with the -i option:
gawk -i math 'BEGIN { print math::sec(math::pi) }'
gawk -i rnd 'BEGIN { print rnd::randString() }'
gawk -i str '{ print str::trim(0ドル) }' <<EOF
	one 
	two 
EOF
  • On scripts with the @include directive:
#!/usr/bin/env -S gawk -E
@include "math"
@include "stats"
BEGIN {
	print math::hypot(3,4)
	A[1] = 10
	A[2] = 20
	print stats::mean(A)
}

📓 API reference

The API reference can be generated with doxygen from comments in the source code. Run from the project's root directory:

make docs-style
make docs

We provide our awkxygen script as an executable so you can also generate API references for your own awk libraries by configuring your Doxyfile like so:

FILE_PATTERNS = *.awk
EXTENSION_MAPPING = awk=c++
INPUT_FILTER = awkxygen

and run doxygen.

The script depends on this library. If it's not installed but you have the source code you can still do:

PATH="$PATH:/path/to/awkl/bin" AWKPATH="/path/to/awkl/src" doxygen

🚀 Installation

📦 From source
  • Dependencies:

    • gawk 5.0+
  • Build dependencies:

    • GNU autotools: autoreconf
git clone --filter=blob:none https://codeberg.org/tplasdio/awkl.git
cd awkl
autoreconf -i
./configure # For system-installation
#./configure --prefix ~/.local # For user-installation
sudo make install
Arch Linux or other pacman distros
curl -O https://codeberg.org/tplasdio/awkl/raw/branch/main/packaging/PKGBUILD-git
makepkg -sip PKGBUILD-git

For uninstallation, run sudo pacman -Rsn gawk-awkl-git.

Other Linux
curl -O https://codeberg.org/tplasdio/awkl/raw/branch/main/packaging/lure-git.sh
lure build -s lure-git.sh
  • Debian, Ubuntu or other .deb distros: apt install ./gawk-awkl-git*.deb
  • Fedora, OpenSUSE or other .rpm distros: rpm -i gawk-awkl-git*.rpm
  • Alpine Linux: apk add --allow-untrusted gawk-awkl-git*.apk

📝 Licence

GPL-3.0-or-later