Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Urgent Stripping comments from a file (awk)

Status
Not open for further replies.

albert

Programmer
Mar 5, 1999
1
US
I have an inputfile that has comments on every line of code and each line begins with a unique format. (asdf ...)<br>
I am trying to write an awk script that would read each line of the <br>
input file and display the output without the comments in an output file. This is a sample line in the file.<br>
asdf........... #comment.<br>
I have tried awk'/asdf/ {print}'inputfile &gt; output file<br>
But it prints out the whole line with the comments<br>
How could I do this ?<br>
Thanks <br>
Albert
 
Try this:<br>
<br>
awk 'BEGIN { FS = "#" }<br>
{ print $1 }' inputfile &gt; output file<br>
<br>

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top