Splitting file when file count exceeded


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Splitting file when file count exceeded
# 1  
Old 03-13-2010
Question Splitting file when file count exceeded

hello everybody,
need help .
i want to write a shell script which will first check the count of the file ,
if file count is greater than 15000 then script will split the file in 15000 each.with count of each splited file included in it.
if file size is less than 15000 then it will not split.

i have used this concept but not working

filename='dump_'`date '+%y%m%d%H%M%S'`'.dat'
count=`wc -l $filename`
if [ $filename -gt 15000 ]
then
split -l 15000 $filename
else
echo " file count is less than 15000"
fi

above script is not running.
also not finding the logic to insert the filecount in each splitted file .....
# 2  
Old 03-13-2010
Code:
if [ $filename -gt 15000 ]

It should be $count what you need to check. rt?

Also, where you want to include the count?
# 3  
Old 03-13-2010
thanks dennis ....i want to include the count in head of each splitted file.
# 4  
Old 03-15-2010
hi all please help!!!!!!
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Splitting the file based on two fields - Fixed length file

Hi , I am having a scenario where I need to split the file based on two field values. The file is a fixed length file. ex: AA0998703000000000000190510095350019500010005101980301 K 0998703000000000000190510095351019500020005101480 ... (4 Replies)
Discussion started by: saj
4 Replies

2. Shell Programming and Scripting

Splitting a text file into smaller files with awk, how to create a different name for each new file

Hello, I have some large text files that look like, putrescine Mrv1583 01041713302D 6 5 0 0 0 0 999 V2000 2.0928 -0.2063 0.0000 N 0 0 0 0 0 0 0 0 0 0 0 0 5.6650 0.2063 0.0000 N 0 0 0 0 0 0 0 0 0 0 0 0 3.5217 ... (3 Replies)
Discussion started by: LMHmedchem
3 Replies

3. Shell Programming and Scripting

Execution of loop :Splitting a single file into multiple .dat file

hdr=$(cut -c1 $path$file|head -1)#extract header”H” trl=$(cut -c|path$file|tail -1)#extract trailer “T” SplitFile=$(cut -c 50-250 $path 1$newfile |sed'$/ *$//' head -1')# to trim white space and extract table name If; then # start loop if it is a header While read I #read file Do... (4 Replies)
Discussion started by: SwagatikaP1
4 Replies

4. Shell Programming and Scripting

Splitting XML file on basis of line number into multiple file

Hi All, I have more than half million lines of XML file , wanted to split in four files in a such a way that top 7 lines should be present in each file on top and bottom line of should be present in each file at bottom. from the 8th line actual record starts and each record contains 15 lines... (14 Replies)
Discussion started by: ajju
14 Replies

5. UNIX for Dummies Questions & Answers

httpd count exceeded threshold limit

Hello Everyone, I am new to this forum and also unix/linux. Our application today threw an alert whcih read as "The users active count on host has crossed the threshold limit of 50 and is standing at 65." This was although cleared when I restarted tomcat. But I am not sure why this count... (0 Replies)
Discussion started by: ykhati
0 Replies

6. Shell Programming and Scripting

Splitting a file in to multiple files and passing each individual file to a command

I have an input file with contents like: MainFile.dat: 12247689|7896|77698080 16768900|hh78|78959390 12247689|7896|77698080 16768900|hh78|78959390 12247689|7896|77698080 16768900|hh78|78959390 12247689|7896|77698080 16768900|hh78|78959390 12247689|7896|77698080 16768900|hh78|78959390 ... (4 Replies)
Discussion started by: rkrish
4 Replies

7. UNIX for Dummies Questions & Answers

File size limit exceeded... SCO ulimit?

Hello - O/S is UnixWare 7.1.4 My prefered method of copying files between servers is 'rcp', which does not recognize symbolic links; therefore, files are duplicated many times over. To avoid this duplication, I would like to use 'tar' and/or 'cpio' and pipe them through 'rcp', but... (1 Reply)
Discussion started by: rm -r *
1 Replies

8. Solaris

/tmp: File system full, swap space limit exceeded

Can you help. My server sunning solaris 9 on x86 platform pretty much hung for a few hours... I could not use telnet or ssh to the box - it kept refusing connection. A few hours later - I was able to log in again. The server has not rebooted but here are the first errors in the messages log... (5 Replies)
Discussion started by: frustrated1
5 Replies

9. HP-UX

Count Exceeded Error on HP-UNIX

Sirs/Madame, On my HP-Unix, I came across an error GRECV-count exceeded and as a result of this, systems got hanged and server came down. Graceful shutdown too was not allowed. Kindly, Can anybody help me out in killing this issue Bhavani.R (0 Replies)
Discussion started by: bhavani2006
0 Replies

10. Programming

File size limit exceeded

When i run my C program which dynamically creates the output file, the program stops after sometime and gives the error "File size limit exceeded" even though my working directory has space.Can anyone plz help me out. (13 Replies)
Discussion started by: drshah
13 Replies
Login or Register to Ask a Question