dotfiles/termscripts/colon2newline.sh

29 lines
521 B
Bash

#!/bin/sh
usage() {
echo "$0 [-r] <Colon separated list>" 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