![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Generating a Subsystem | funksen | AIX | 0 | 07-14-2008 04:43 AM |
| Generating xls with utf-8 format | kalyanramurs | Shell Programming and Scripting | 0 | 06-21-2008 07:27 AM |
| Generating files with time interval of fifteen minutes | aajan | Shell Programming and Scripting | 0 | 09-25-2007 01:54 AM |
| Generating files of specific size | nxd25 | Shell Programming and Scripting | 2 | 06-27-2006 11:06 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Generating files.
I/P file name:- 20092008.txt
Check number of entries in i/p file by following command ChkEnt –infl 20092008.txt -opfl 20092008_test.txt >count.txt Dear Friends, Please help me in automating following thing. If output generated (count.txt) is having value more than 1000 i.e. say it has shown 3521 entries Then, system should split file as follows Splt –infl 20092008.txt –opfl 20092008_1.txt –b 0 –e 1000 Splt –infl 20092008.txt –opfl 20092008_2.txt –b 1001 –e 2000 Splt –infl 20092008.txt –opfl 20092008_3.txt –b 2001 –e 3000 Splt –infl 20092008.txt –opfl 20092008_4.txt –b 3001 –e 3521 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 |
|
||||
|
Dear Tytalus, thanx for your quick reply.
I m new to unix n all, so can u plz tell me following things 1. Can we use "cat" option i.e. cat count.txt to assign that count value to variable x? e.g x=`cat count.txt` 2. 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? |
|
|||||
|
no worries.
cat will simply spew the file out. 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 |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|