Colon separated list to regex or newline scripts
This commit is contained in:
parent
b895021361
commit
0f43640f29
|
@ -0,0 +1,28 @@
|
|||
#!/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
|
|
@ -0,0 +1,28 @@
|
|||
#!/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/:/\/.*\\|/g'
|
||||
else
|
||||
echo "\($1\)" | sed 's/:/\\|/g'
|
||||
fi
|
Loading…
Reference in New Issue