#! /bin/bash # example input: ./inverse -1-2-3- 1 15 # example output: -4-5-6-7-8-9-10-11-12-13-14-15- a=$1 b=$2 c=$3 inv="-" for i in `seq $b $c`; do tmp="-"$i"-" found=$(gawk -v a=$a -v tmp=$tmp 'BEGIN{print index(a,tmp)}') if (($found==0)) then inv=$inv$i"-" fi done echo $inv