Thursday, June 7, 2012

"Grep," Sed Awk

KNOWN: 
  • File format =      fileName     last_mod_time     #compiles
  • fileName

How many times has it been compiled? 
     
     grep -a fileName modLogFile.txt | awk '{print $3}'

     (finds line containing fileName, prints the third column)

Reset Last Number to Zero

     sed -i -e '/fileName/s/\(.*\)[0-9]./\10/' modLogFile.txt
     (in line of modLogFile.txt containing fileName, replaces the last number (including multiple digits) with number 0)
      -i means in place, -e means edit (use both to edit original file), s is for sub, (.*) means A thing and perhaps some after,
      [0-9] means number, escaped 1 means LAST instance, modLogFile.txt is original file

References
man sed
man awk
man grep
       

No comments:

Post a Comment