Here the script should be smart enough to calculate number of files to be generated automatically by looking at total no of entries in original file i.e. 3521 in earlier example.
Thank you in advance.
I am waiting for your reply
Bye and take care
No, my system works differently, it does not split file by line count. It works on a logic n that logic is incorporated the command that i hv mentioned i.e. Splt
Dear Tytalus, thanx for your quick reply.
I m new to unix n all, so can u plz tell me following things
Can we use "cat" option i.e. cat count.txt to assign that count value to variable x?
e.g
x=`cat count.txt`
Honestly i coulnt undrstnd this statement.
while [ $x -gt 1000 ]; do echo Splt -infl 20092008.txt -opfl 20092008_${y} -b $(expr $y \* 1000 + 1) -e $(expr $y \* 1000 + 1000); y=$(expr $y + 1); x=$(expr $x - 1000); done ; echo Splt -infl 20092008.txt -opfl 20092008_2 -b $(expr $y \* 1000 + 1) -e $(expr $y \* 1000 + $x)
Can u jst tell me, is the script smart enough to handle even if a particular file has n number of records? or it can handle only 3521 entries?
wc will give you a word count (and the -l will be the number of lines alone).
Yes - the script should work for any length file - it simply sets a variable x as the number of lines, then repeatedly subtracts 1000 and spts out each individual command, until x' is less than 100 - then the loop finishes and it kicks out the final splt command
Ohh wow, why this logic didnt strike me, was thinking about the logic since 2-3 days...
Any ways, will try this on Monday evening. Will let you know if I need more help.
Thanx a lot for your help.
Bye & God bless you,
All the best
One more thing, if you dont mind, can u further simplify this 'while' statement?
I mean can u make it such a way that even a lay-man like me can easily understand it? No matter if it will become lil bigger... It will help me in maintaining it in better way, n also i can make changes in it if necessary in near future.. plz