lib_gnucompat.sh
GNU-Tools Compatibility Layer:
This script provides compatibility functions for GNU tools on non-GNU systems, such as macOS.
Usage:
MY_PATH="$(realpath "${BASH_SOURCE[0]}")"
SCRIPT_DIR="$(dirname "${MY_PATH}")"
readonly MY_PATH
readonly SCRIPT_DIR
readonly LIB_BASH_DIR="${SCRIPT_DIR}/lib_bash"
source "${LIB_BASH_DIR}/lib_gnucompat.sh"
Tools Aliases
These functions will return the corresponding GNU-tool on non-GNU systems,
if available. Such as gsed
on macOS, which is the GNU version of sed
.
SED
: GNUsed
commandAWK
: GNUawk
commandGREP
: GNUgrep
commandFIND
: GNUfind
commandSORT
: GNUsort
commandTAR
: GNUtar
commandDATE
: GNUdate
commandXARGS
: GNUxargs
commandCUT
: GNUcut
commandHEAD
: GNUhead
commandTAIL
: GNUtail
commandTR
: GNUtr
commandUNIQ
: GNUuniq
commandWC
: GNUwc
commandDIFF
: GNUdiff
command
Functions
is_gnu
Signal, if the given tool is a GNU tool.
Usage:
if ! is_gnu "sed"; then
echo "Not a GNU tool."
fi