Hello
kraljic,
I have a few to questions pose in response first:-
- What have you tried so far?
- What output/errors do you get?
- What OS and version are you using?
- What are your preferred tools? (C, shell, perl, awk, etc.)
- What logical process have you considered? (to help steer us to follow what you are trying to achieve)
Most importantly,
What have you tried so far?
There are probably many ways to achieve most tasks, so giving us an idea of your style and thoughts will help us guide you to an answer most suitable to you so you can adjust it to suit your needs in future.
Did
split help, it's probably the right tool for this, unless you want to do other processing at the same time. With
split you can break up your file based on the number of bytes, lines, etc. and define output filenames and suffix length to make it suitable. It will not easily take the literal name
file1 and generate a
file2, but you can force it to be something sensible and then rename the output as needed.
If you generate 5 files of output and want to be separating out just the content of the first, it is straightforward to rename that one to the desired name and either delete the remainder or
cat them back together (in the right order) to overwrite the original file, thereby removing the lines you have just extracted. You would then need to tidy the temporary files up too to save space.
We're all here to learn and getting the relevant information will help us all.
Have a go with
split as my learned member
RudiC suggests and let us know if it helps or you get stuck. I'm sure we can get a working solution that you can support and/or reuse.
kind regards,
Robin