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
Should be something like this:
awk '/^c/{f=1}f{$0 = "#" $0}{print}' file
Thanks that works well
May I ask where can read on reference for
f{$0 = "#" $0} ?
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
sed '/c/,$s/^/#/' yourfile
awk '/^c/,eof{$0="#"$0}1' file