The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM



Thread: Not working
View Single Post in UNIX Forums - Click on the Thread or Permalink to View Entire Thread -->
  #5 (permalink)  
Old 05-11-2007
vgersh99's Avatar
vgersh99 vgersh99 is online now
Moderator
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 3,180
Quote:
Originally Posted by jim mcnamara
Code:
#!/bin/ksh                                                                       
                                                                                 
okay=$(head -1 $1 | awk '{print substr($0, length($0)-2)}' | \
       awk '{print index("001|004|007",$0)}')                                                              
if  [[ $okay -gt 0 ]]  then
      print "okay"
else
      print "not okay"
fi
jim nice idea, it does not work - at least not with Solaris's 'nawk'.
Couple of things:
  1. the 'index' signature is wrong: index(s,t): Return the position, in characters, numbering from 1,
  2. 't' is a STRING and not a regex (at least on Solaris' "nawk"
Reply With Quote