View Single Post

  #1 (permalink)  
Old 10-29-2007, 09:49 PM
vikas027 vikas027 is offline
Member
User
 
Join Date: Oct 2007
My distro: Linux RHEL 5
Posts: 33
Rep Power: 0
vikas027 is on a distinguished road
Unhappy split files by specifying a string (bash shell)

Hi all,

I have a file of around 300 lines in which string "SERVER" occurs around 32 times.

for eg.
Quote:
SERVER
.....
.....
....

SERVER

.....
.....
....

SERVER.....
.....
....
I need to split files like, for eg

Quote:
file1
SERVER
....
....
....

file2
SERVER
.....
...
....


file3
SERVER
.....
....
....
I am using this code
awk '/SERVER/{n++}{print > f n}' f=/vikas/list /vikas/final

But the problem is that it makes maximum of 10 files, but I need more than 30.
I have tried using nawk, but didnt worked. This cmd is running fine in Linux, But not in Sun OS (Solari.
I am using bash scripting on Sun OS.


Any other way of splitting this data ???

Pls help !!!

Thanks in adv.
Regards,
Vikas

Last edited by vikas027; 10-29-2007 at 11:58 PM.
Reply With Quote