From bd85ecc0a647d0475bb646b293bef65b09cc09d0 Mon Sep 17 00:00:00 2001 From: Pekka Helenius Date: Fri, 19 Feb 2021 13:49:39 +0200 Subject: [PATCH] Add whichcmd --- tools/whichcmd.sh | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 tools/whichcmd.sh diff --git a/tools/whichcmd.sh b/tools/whichcmd.sh new file mode 100644 index 0000000..b630b1b --- /dev/null +++ b/tools/whichcmd.sh @@ -0,0 +1,15 @@ +#!/bin/env sh + +if [[ ${1} == "-h" ]] || [[ ${1} == "--help" ]] || [[ -z ${1} ]]; then + echo " +Find available commands in PATH by input syntax. +Usage: $(basename $0) +" + exit 0 +fi + +PATHS=($(echo "${PATH}" | sed 's/:/ /g') ) + +for p in ${PATHS[@]}; do + find "${p}" -iname "*${1}*" +done