Issue with Splitting of file


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users Issue with Splitting of file
# 1  
Old 05-17-2007
Issue with Splitting of file

HI! All
Iam running this script ro split the file ,attact a timesatmp to it and then conver it to .tmp extension

cd /home/staff/thussain
Prefix=Z_PRICE_NEW_`date "+%Y%m%d%H%M%S"`
split -3000 -a 5 /home/staff/thussain/Z_PRICE_NEW.txt $Prefix
find . -name "$Prefix*" -print | {
while read FILE;
do
mv $FILE $FILE.tmp
done
}
out put
Z_PRICE_NEW_20070517014630aaaac.tmp
Z_PRICE_NEW_20070517014630aaaaa.tmp.tmp

but sone file are coming with tmp extension twice ,and any on tell me how to resolve this issue..

Thanks in Advance

Regards

Tausif
# 2  
Old 05-17-2007
Put the output files into a second directory, the find statement is also finding the new files that you are creating and then processing them again.
# 3  
Old 05-17-2007
It seems like you are having left over files from previous splits.
The "split" command does not remove files prior to execution.
What I recommend you to do is to clean up the output split
files first before you issue the command:
Code:
...
Prefix=Z_PRICE_NEW_`date "+%Y%m%d%H%M%S"`
rm -f $Prefix*
split -3000 -a 5 /home/staff/thussain/Z_PRICE_NEW.txt $Prefix
...

# 4  
Old 05-17-2007
I think script is finding the files which are already been given .tmp extension. So it might be giving the problem
# 5  
Old 05-18-2007
So how to handle this issue becasue these files needs to be pickedup from the same location by SAP XI
# 6  
Old 05-19-2007
I think if you eliminate the files having .tmp extension from the list of files into which you are looping, this problem will be solved. Code would be something like this,

cd /home/staff/thussain
Prefix=Z_PRICE_NEW_`date "+%Y%m%d%H%M%S"`
split -3000 -a 5 /home/staff/thussain/Z_PRICE_NEW.txt $Prefix
find . -name "$Prefix*" -print | grep -v '.tmp$' | {
while read FILE;
do
mv $FILE $FILE.tmp
done
}
# 7  
Old 05-20-2007
you can give a !, an example
Code:
find . ! -name "*tmp" -a -name "$Prefix*"  .......

something like that...
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

awk issue splitting a fixed-width file containing line feed in data

Hi Forum. I have the following script that splits a large fixed-width file into smaller multiple fixed-width files based on input segment type. The main command in the script is: awk -v search_col_pos=$search_col_pos -v search_str_len=$search_str_len -v segment_type="$segment_type"... (8 Replies)
Discussion started by: pchang
8 Replies

4. Shell Programming and Scripting

Issue splitting file based on XML tags

more a-d.txt1 <a-dets> <a-serv> <aserv>mymac14,mymac15:MYAPP:mydom:/web/domain/mydom/config <NMGR>:MYAPP:/web/bea_apps/perf/NMGR/NMGR1034 <a-rep-string> 11.12.10.01=192.10.00.26 10.20.18.10=192.10.00.27 </a-rep-string> </a-serv> <w-serv>... (2 Replies)
Discussion started by: mohtashims
2 Replies

5. 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

6. 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

7. Shell Programming and Scripting

Issue in splitting a file

Hi, I have a file (named as values) which contains around 10 columns with an unique number in the first column. I wanted to segregate the file into 10 files based on the range of the Unique number. It varies from 0 to 10 Million. So, I need to split the file into 10 files with ranges from 0 to... (8 Replies)
Discussion started by: b@l@ji
8 Replies

8. 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

9. Shell Programming and Scripting

Issue while splitting a row of record

Hi, I have one file with the following details, ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Account_Id Date Id Balance 44 9 1000.00 30 15-10-2173 10 1000.00 42 15-10-2173 10 1200.00 53 01-01-2008 10 1200.00 I need to split up the values in to the respective fields as follows, ... (7 Replies)
Discussion started by: Kattoor
7 Replies

10. UNIX for Dummies Questions & Answers

Splitting a file based on record sin another file

All, We receive a file with a large no of records (records can vary) and we have to split it into two files based on another file. e.g. File1: UHDR 2008112 "25187","00000022","00",21-APR-1991,"" ,"D",-000000519,+0000000000,"C", ,+000000000,+000000000,000000000,"2","" ,21-APR-1991... (7 Replies)
Discussion started by: er_ashu
7 Replies
Login or Register to Ask a Question