Sponsored Content
Top Forums UNIX for Beginners Questions & Answers Split the all files in to 8 parts in a folder Post 303040866 by Raghuram717 on Friday 8th of November 2019 04:00:48 AM
Old 11-08-2019
Split the all files in to 8 parts in a folder

Hi,

I have different files and i need to split the files in that folder split in to 8 parts with equal number of lines....!
any fastest way of doing this in awk.

for an example i have a file called "BillingDetails_BaseFile.csv" with total line count 65536 and i need to split in to 8 parts with each file having 8192 (8192*8=65536). if 65538,last two lines can be ignored. i had a logic for this but its taking long time for this.
any fastest way in awk is appreciated.

my code:
Code:
cd /tmp/data/
linecount=$(wc -l BillingDetails_BaseFile.csv|cut -d" " -f1)
echo "linecount=$linecount"
b=$(expr  ${linecount} / ${Split_Count} )
echo "spliting lines per file will be ${b}"
split -l${b} -d BillingDetails_BaseFile.csv BillingDetails_
chmod 777 *

c=$(expr  ${Split_Count} - 1  )
for (( i=${c}; i>=0; i-- ))
do
  a=$({ printf "%02d\n" $i ; })
  b=$(expr  ${i} + 1  )
  b=$({ printf "%02d\n" $b ; })
  mv BillingDetails_$a BillingDetails_$b
done

any fastest way just specifying the folder name it should go each file and look for line count and split the 8 parts with equal number of lines.
Any help in awk is appreciated.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Split folder into dvd size

Hello everyone, I have a big folder in a linux server that contains dozen of big files (total folder size ~ 50 GB) I have a couple of files of 2.5 GB and some others from 100 MB to 1 GB. (that said it's obvious that it's impossible having two 2.5 GB files in one dvd) The purpose is to... (7 Replies)
Discussion started by: cabrao
7 Replies

2. Shell Programming and Scripting

Using bash to separate files files based on parts of a filename

Hey guys, Sorry for the basic question but I have a lot of files that I want to separate into groups based on filenames which I can then cat together. Eg I have: (a_b_c.txt) WB34_2_SLA8.txt WB34_1_SLA8.txt WB34_1_DB10.txt WB34_2_DB10.txt WB34_1_SLA8.txt WB34_2_SLA8.txt 77_1_SLA8.txt... (1 Reply)
Discussion started by: Breentax
1 Replies

3. Shell Programming and Scripting

Incrementing parts of ten digits number by parts

I have number in file which contains date and serial number: 2013101000. The last two digits are serial number (00). So maximum of serial number is 100. After reaching 100 it becomes 00 with incrementing 10 which is day with max 31. after reaching 31 it becomes 00 and increments 10... (31 Replies)
Discussion started by: Natalie
31 Replies

4. Shell Programming and Scripting

Split file into n parts.

Hi all: I have a 5-column tab-separated file. The only thing that I want to do with it is to split it. However, I want to split it with a 80/20 proportion -- randomized, if possible. I know that something like : awk '{print $0 ""> "file" NR}' RS='' input-file will work, but it only... (6 Replies)
Discussion started by: owwow14
6 Replies

5. UNIX for Dummies Questions & Answers

How To Split A File In Two Rar Parts?

I Am connected to Whatbox.ca Seed Box Via SSH!! i have a file named avicii.mp3. I Want to split it into two rar parts as Apart1.rar and Apart2.rar So That When i Download Both the parts to My PC And Extract Them They Come out As Whole Avicii.mp3. There is also one more problem!! When I Rar A... (18 Replies)
Discussion started by: anime12345
18 Replies

6. UNIX for Dummies Questions & Answers

Split a file into parts only if the first field is different

Hi, I have a file like this: aaa 123 aaa 223 aaa 225 bbb 332 bbb 423 bbb 6755 bbb 324 ccc 112 ccc 234 ccc 897 Which I need to split into several files, something like split -l 3 but the way that the lines with the same names would only go into one file: (7 Replies)
Discussion started by: coppuca
7 Replies

7. Shell Programming and Scripting

Split a folder with huge number of files in n folders

We have a folder XYZ with large number of files (>350,000). how can i split the folder and create say 10 of them XYZ1 to XYZ10 with 35,000 files each. (doesnt matter which files go where). (12 Replies)
Discussion started by: AlokKumbhare
12 Replies

8. Shell Programming and Scripting

Split line in 4 parts

Hi Guys, I have file A.txt 1 2 3 4 5 6 7 8 9 10 11 Want Output :- 1 2 3 (3 Replies)
Discussion started by: pareshkp
3 Replies

9. Shell Programming and Scripting

Shell scripting for moving folder specific files into target directory of that country folder.

I need help to write shell script to copy files from one server to another server. Source Directory UAE(inside i have another folder Misc with files inside UAE folder).I have to copy this to another server UAE folder( Files should be copied to UAE folder and Misc files should be copied in target... (3 Replies)
Discussion started by: naresh2389
3 Replies

10. Shell Programming and Scripting

Request for Shell script to move files from Subfolder to Parent folder and delete sub folder

Hi Team, I am new to shell script and there is a requirement where files should be moved from Subfolder to parent folder. Eg: parent folder --> /Interface/data/test/IN Sub folder -->/Interface/data/test/IN/Invoice20180607233338 Subfolder will be always with timestamp... (6 Replies)
Discussion started by: srivarun15
6 Replies
deb-split(5)							      Debian							      deb-split(5)

NAME
deb-split - Debian multi-part binary package format SYNOPSIS
filename.deb DESCRIPTION
The multi-part .deb format is used to split big packages into smaller pieces to ease transport in small media. FORMAT
The file is an ar archive with a magic value of !<arch>. The file names might contain a trailing slash (since dpkg 1.15.6). The first member is named debian-split and contains a series of lines, separated by newlines. Currently seven lines are present. The first is the format version number, 2.1 at the time this manual page was written. The second is the package name. The third is the package ver- sion. The fourth is the md5sum of the package. The fifth is the total size of the package. The sixth is the maximum part size. The seventh is the current part number, followed by a slash and the total amount of parts (as in '1/10'). Programs which read multi-part archives should be prepared for additional lines to be present, and should ignore these if this is the case. If the version number has changed, an incompatible change has been made and the program should stop. If it has not, then the program should be able to safely continue, unless it encounters an unexpected member in the archive (except at the end), as described below. The second, last required member is named data.N, where N denotes the part number. It contains the raw part data. These members must occur in this exact order. Current implementations should ignore any additional members after data.N. Further members may be defined in the future, and (if possible) will be placed after these two. SEE ALSO
deb(5), dpkg-split(1). Debian Project 2010-01-28 deb-split(5)
All times are GMT -4. The time now is 07:16 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy