The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #2 (permalink)  
Old 03-18-2009
jim mcnamara jim mcnamara is online now Forum Staff  
...@...
  
 

Join Date: Feb 2004
Location: NM
Posts: 5,767
arrays start the index from zero not one.

If you want to prove existence of one of the array elements in the file comp.txt
using grep:
Code:
grep -q -e "${rtab[1]}"  -e "${rtab[2]}" -e "${rtab[3]}" -e "${rtab[4]}" -e "${rtab[4]}" comp.txt
if [[ $? -eq 0 ]] ; then
  echo "found"
else
  echo "not found"
fi