#!/bin/bash FILES=( default.cbd ) COMPREPLY=() k=${#FILES[@]} for (( i=0; i < $k; i++ )); do for j in `grep -s -E 'invoke .*.cbd' ${FILES[i]} | cut -d' ' -f2`; do FILES[$k]="$j"; let k+=1 done done rm -fr tmp k=0 for i in ${FILES[@]} ; do echo $i >> tmp done tmp=`sort -u tmp` rm -fr tmp for i in $tmp; do if [ -f $i ] ; then for j in `grep -E '(if|get)opt [^\s]+' $i | cut -d' ' -f2`; do if [[ "$j" != "ifopt" ]] ; then echo $j >> tmp fi done fi done k=0 for i in `sort -u tmp`; do COMPREPLY[$k]=$i let k+=1 done rm -fr tmp #echo ${COMPREPLY[*]}