Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
I am facing a problem while spliting a text file, i need to split a file into some parts and each splited file sholld have 2000 lines, when i do it through "split" command the mother file is kept intact but as per my requirment i need to cut mother file into some parts thus it should not be kept intact .
The first file split produces is what you want 'motherfile.txt' to be. If you no longer want 'motherfile.txt', then just delete it. If that's not what you mean, sorry for misunderstanding and maybe you could try explaining again.
As postd in previously. as per my requirement motherfile should not be deleted but it only should be splited in some parts because my another application that contineously writes some text in motherfile.txt doesnt respond when i delete motherfile.
You do not tell why you want to do it the way you mention and I wonder if that will give the desired result....
As you mentioned, the application keeps writing to the motherfile. If you split the motherfile itself (leave the first 2000 lines, put the rest into childfile's), new lines will be appended to the motherfiles. This will mix old and new lines and (assuming you want to do this more then once) the first 2000 lines will _always_ be the same (those "old" 2000 lines from the first split).
The solution I gave in post #3 will leave the motherfile alone. All that is in it will still be there after splitting, the content will be spread (2000 lines per file) into multiple childfile's. You could make the motherfile empty immediately after the split command (The following will make it empty without disturbing the application > motherfile.txt) so it keeps collecting and work on the childfile(s).
If the childfiles are needed later on you could give them a date stamp: split -d -l 2000 motherfile.txt childfile.$(date '+%C%Y%m%d').