diff --git a/termscripts/colon2newline.sh b/termscripts/colon2newline.sh new file mode 100644 index 0000000..6c051b4 --- /dev/null +++ b/termscripts/colon2newline.sh @@ -0,0 +1,28 @@ +#!/bin/sh + +usage() { + echo "$0 [-r] " 1>&2 + echo "[-r] Adds /.* at the end of each entry as if they were folders" 1>&2 + exit 1 +} + +# To get options provided to the command +while getopts ":r" option; do + case "${option}" in + r) + recursive="1" + ;; + * | h) + usage + ;; + esac +done +shift $((OPTIND-1)) + +[ -z "$1" ] && exit 1 + +if [ "$recursive" = "1" ]; then + echo "$1/.*" | sed 's/:/\/.*\n/g' +else + echo "$1" | tr ':' '\n' +fi diff --git a/termscripts/colon2regex.sh b/termscripts/colon2regex.sh new file mode 100644 index 0000000..5baf39b --- /dev/null +++ b/termscripts/colon2regex.sh @@ -0,0 +1,28 @@ +#!/bin/sh + +usage() { + echo "$0 [-r] " 1>&2 + echo "[-r] Adds /.* at the end of each entry as if they were folders" 1>&2 + exit 1 +} + +# To get options provided to the command +while getopts ":r" option; do + case "${option}" in + r) + recursive="1" + ;; + * | h) + usage + ;; + esac +done +shift $((OPTIND-1)) + +[ -z "$1" ] && exit 1 + +if [ "$recursive" = "1" ]; then + echo "\($1/.*\)" | sed 's/:/\/.*\\|/g' +else + echo "\($1\)" | sed 's/:/\\|/g' +fi