יום חמישי, 16 במאי 2013

Simple bash and awk program

A simple bash program:

echo "Start "
#Iterate over all the files in the Logs directory
for nextLogFile in Logs/*
do
    #pring the file
    echo $nextLogFile
 
  /*
        for every file  cat stream its content into the awk
        the awk print the 2nd space delemeted word in each line
        in the end of the iteration over the lines print "done"   
    */
    cat $nextLogFile|awk '{print $2}{print "done"}'
   
 
   /*
        for every file cat stream its content into the awk
        the awk test using regex if the 2nd space delemeted word in each line
        start with G or S if yes then its print the word    
    */
    cat $nextLogFile|awk '{
        theName = $2   
        if ( theName ~ /[GS]/)
            print theName;
        }'
done
echo "End"

אין תגובות:

הוסף רשומת תגובה