The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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 -->
  #5 (permalink)  
Old 03-19-2009
ddrew78 ddrew78 is offline
Registered User
  
 

Join Date: Mar 2009
Posts: 8
Re: Find line before blank

Quote:
Originally Posted by aaaaargh View Post
Here is mine, ugly but should do the trick

(not tested)

Code:
awk 'BEGIN{i=0}
  { content[NR]=$0; if (($0=="")) {b[i]=NR;i++} j++;} 
  END 
 { 
   for (x=0;x<=b[0];x++) 
  {print content[x] > "file1" } for (x=b[1];x<=j; x++) { print content[x] > "file2"}   
}'  /var/tmp/file


Thanks for the reply. Unfortunately I'm new to this and can't figure out how to implement this into my script. Below is the last two lines of the script to get the file I had above.

system "dos2unix ansi3 > ansi7";
system "mv ansi7 ansi3";

Thanks again for any help.