23 lines
473 B
Bash
23 lines
473 B
Bash
#! /bin/bash
|
|
|
|
# Gets the full range of combinations of a given number
|
|
#seq 1234 4321 | grep 1 | grep 2 | grep 3 | grep 4
|
|
|
|
re='^[0-9]+$'
|
|
if ! [[ $1 =~ $re ]] ; then
|
|
echo "This command only accepts one input and it must be a number."
|
|
echo "";
|
|
echo "Example:";
|
|
echo "$0 1234"
|
|
exit 1;
|
|
fi
|
|
|
|
IN=$1;
|
|
REV_IN=$(echo $1 | rev);
|
|
PIPES="";
|
|
for ((i=0; i < ${#IN}; i++)); do
|
|
ARR[$i]=$((${IN:$i:1}));
|
|
PIPES="$PIPES | grep ${IN:$i:1}";
|
|
done
|
|
|
|
eval "seq $IN $REV_IN $PIPES"; |