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 -->
  #4 (permalink)  
Old 07-04-2009
cfajohnson's Avatar
cfajohnson cfajohnson is offline Forum Advisor  
Shell programmer, author
  
 

Join Date: Mar 2007
Location: Toronto, Canada
Posts: 2,365


Code:
awk '/^c/{f=1}     ## If the first character of the line is "c" set f = 1
  f {$0 = "#" $0}  ## if f is not equal to 0, add "#" to beginning of line
  {print}          ## print every line
' file