The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




Thread: Delete help
View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #4 (permalink)  
Old 10-12-2008
radoulov's Avatar
radoulov radoulov is online now Forum Staff  
addict
  
 

Join Date: Jan 2007
Location: Варна, България / Milano, Italia
Posts: 2,915

Code:
perl -00 -nle'print unless/^a.*\n^a/im&&!/^A/m' filename

Edit: Just saw you want only the comments, so it depends, you may try something like this:


Code:
perl -00 -nle'/^[A#]/m and print' filename

But it will fail on an input like this:


Code:
# 
a 4 234 gfg
a 4 566 erer

With AWK you can try something like this, but it will fail in too many situations:


Code:
awk '/[A#] */' ORS='\n\n' RS= filename


Last edited by radoulov; 10-12-2008 at 05:17 PM..