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 -->
  #1 (permalink)  
Old 07-04-2009
phamp008 phamp008 is offline
Registered User
  
 

Join Date: Jan 2008
Posts: 36
using awk to comment out lines to the end of file

Hello,

I have a file as follow

a
b
c
c
d
d
e


I would like to write a awk command to insert # from the first occurence of
"c" to the end of the files.
OUTPUT should be like this

a
b
#c
#c
#d
#d
#e

I kept getting error while attempting to use break

awk ' if ( $1 ~ /^c/ ) { beginline = NR ; break } '

Greatly appreciate your comment