Results 1 to 8 of 8

Thread: split files by specifying a string (bash shell)

Threaded View

  1. #1
    Member
    Join Date
    Oct 2007
    Posts
    37
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Rep Power
    0

    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.
    SERVER
    .....
    .....
    ....

    SERVER

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

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

    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 (Solaris).
    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; 29th October 2007 at 11:58 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. shell script to open log files and check for faults
    By trueman82 in forum Shell scripting
    Replies: 3
    Last Post: 26th March 2013, 09:33 AM
  2. How can I set Path in bash shell
    By chanderbio in forum Shell scripting
    Replies: 10
    Last Post: 29th March 2012, 10:37 PM
  3. SCP with a bash shell password linux and unix servers
    By jerry in forum Networking, Firewalls and Security
    Replies: 1
    Last Post: 9th June 2007, 05:53 PM
  4. Replies: 2
    Last Post: 8th February 2007, 03:45 PM
  5. example for string connect to a command.
    By ryan in forum Shell scripting
    Replies: 2
    Last Post: 22nd February 2005, 01:05 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •