This is a discussion on split files by specifying a string (bash shell) within the Shell scripting forums, part of the Development/Scripting category; Hi all, I have a file of around 300 lines in which string "SERVER" occurs around 32 times. ...
|
|||||||
| Register | FAQ | Members List | Calendar | Mark Forums Read |
|
|||
|
Hi all,
I have a file of around 300 lines in which string "SERVER" occurs around 32 times. for eg. Quote:
Quote:
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. |
|
|||
|
Quote:
Hi, Well I am explaining it again. I have a file say final.txt, which has some data in it. For e.g. Quote:
As in this case, it may be: Quote:
awk '/SERVER/{n++}{print > f n}' f=/vikas/list /vikas/final But the problem I am facing is that my actual file final.txt is pretty big, which needs to splitted into around 30 files, which is however not being possible by this command, as it can only split upto 10 files at max only. Hope I have made my point clear. Thanks. |
|
|||
|
Hi,
I tried lots of commands including the above ones. They all run fine on Linux machines BUT not on the solaris machines, dont know the reason behind it. Anyways, MANY MANY THANKS to all for your time and help. I found this command to work perfectly. Code:
/usr/xpg4/bin/awk '/SERVER/{n++}{print > f n}' f=/vikas/list /vikas/final
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How can I set Path in bash shell | chanderbio | Shell scripting | 2 | 06-13-2008 10:38 AM |
| SCP with a bash shell password linux and unix servers | jerry | Networking, Firewalls and Security | 1 | 06-09-2007 05:53 PM |
| Shell script for automatic conversion of files in tar files | kasimani | Shell scripting | 2 | 02-08-2007 03:45 PM |
| shell script to open log files and check for faults | trueman82 | Shell scripting | 1 | 11-23-2006 02:35 AM |
| example for string connect to a command. | ryan | Shell scripting | 2 | 02-22-2005 01:05 PM |