07-17-2009
'-type f' means "only look for regular files". Other options might be 'd' for directories, 'l' for links, ...
The '+5M' doesn't work because it's apparently only implemented in GNU find. Sorry for that.
The awk line uses the 5th field of the output from 'ls -l' (which is the size) and prints it divided by 2.
-b tells split to split after that many bytes (from the awk above). The 2 others are the file itself that needs splitting and the prefix for the new name (sadly, requires full path).
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi Friends,
Below is my requirement. I have a file with the below structure.
0001A1....
0001B1..
....
0001L1
0002A1
0002B1
......
0002L1
..
the first 4 characters are the sequence numbers for a record, A record will start with A1 and end with L1 with same sequence number. Now the... (2 Replies)
Discussion started by: diva_thilak
2 Replies
2. Shell Programming and Scripting
Hello, I have a large file (2GB) that I would like to split based on pattern and size.
I've used the following command to split the file (token is "HELLO")
awk '/HELLO/{i++}{print > "file"i}' input.txt
and the output is similar to the following (i included filesize in KB):
10 ... (2 Replies)
Discussion started by: jl487
2 Replies
3. Shell Programming and Scripting
Hi,
I've one requirement. I have to split one comma delimited file into multiple files based on one of the column values.
How can I achieve this Unix
Here is the sample data. In this case I have split the files based on date column(c4)
Input file
c1,c2,c3,c4,c5... (1 Reply)
Discussion started by: manasvi24
1 Replies
4. Shell Programming and Scripting
I need to split a file if it is over 2GB in size (or any size), preferably split on the lines. I have figured out how to get the file size using awk, and I can split the file based on the number of lines (which I got with wc -l) but I can't figure out how to connect them together in the script.
... (6 Replies)
Discussion started by: ssemple2000
6 Replies
5. Shell Programming and Scripting
Dear All,
I have the following file tabulated:
ID distanceTSS score
8434 571269 10
10122 393912 9
7652 6 10
4863 1451 9
8419 39 2
9363 564 21
9333 7714 22
9638 8334 9
1638 1231 11
10701 918 1000
6587 32056 111
What I would like to do is the following, create 100 new files based... (5 Replies)
Discussion started by: paolo.kunder
5 Replies
6. Shell Programming and Scripting
Hi all.
I've tried searching the web but could not find similar problem to mine.
I have one large file to be splitted into several files based on the matching pattern found in each row.
For example, let's say the file content:
... (13 Replies)
Discussion started by: aimy
13 Replies
7. Shell Programming and Scripting
I have a file that is about 7 GB in size. The requirement is I should split the file equally in such a way that the size of the split files is less than 2Gb. If the file is less than 2gb, than nothing needs to be done. ( need to done using shell script)
Thanks, (4 Replies)
Discussion started by: rudoraj
4 Replies
8. UNIX for Dummies Questions & Answers
Hi All,
I have a UNIX script which reads "PxyType" (read PxyType) as input from user and a file (eg : "File.json") with the list all PxyType's.
Based on the user input for "PxyType" in "File.json", I want to redirect each matched line to a different file ("File1,2,3,..json").
Can you... (7 Replies)
Discussion started by: Deena1984
7 Replies
9. Shell Programming and Scripting
I have a huge file (around 4-5 GB containing 20 million rows) which has text like:
<EOFD>11<EOFD>22<EORD>2<EOFD>2222<EOFD>3333<EORD>3<EOFD>44<EOFD>55<EORD>66<EOFD>888<EOFD>9999<EORD>
Actually above is an extracted file from a Sql Server with each field delimited by <EOFD> and each row ends... (8 Replies)
Discussion started by: amvip
8 Replies
10. UNIX for Beginners Questions & Answers
Hi,
I have a directory in Unix and there are folders available in the directory.
Files are created on different month and now i have a requirement to calculate size of the folder on month basis.
Is there any Unix command to check this please??
Thanks (6 Replies)
Discussion started by: Nivas
6 Replies
LEARN ABOUT OPENSOLARIS
split
split(1) User Commands split(1)
NAME
split - split a file into pieces
SYNOPSIS
split [-linecount | -l linecount] [-a suffixlength]
[file [name]]
split [-b n | nk | nm] [-a suffixlength] [file [name]]
DESCRIPTION
The split utility reads file and writes it in linecount-line pieces into a set of output-files. The name of the first output-file is name
with aa appended, and so on lexicographically, up to zz (a maximum of 676 files). The maximum length of name is 2 characters less than the
maximum filename length allowed by the filesystem. See statvfs(2). If no output name is given, x is used as the default (output-files will
be called xaa, xab, and so forth).
OPTIONS
The following options are supported:
-linecount | -l linecount
Number of lines in each piece. Defaults to 1000 lines.
-a suffixlength
Uses suffixlength letters to form the suffix portion of the filenames of the split file. If -a is not specified, the default suffix
length is 2. If the sum of the name operand and the suffixlength option-argument would create a filename exceeding NAME_MAX bytes, an
error will result; split will exit with a diagnostic message and no files will be created.
-b n
Splits a file into pieces n bytes in size.
-b nk
Splits a file into pieces n*1024 bytes in size.
-b nm
Splits a file into pieces n*1048576 bytes in size.
OPERANDS
The following operands are supported:
file The path name of the ordinary file to be split. If no input file is given or file is -, the standard input will be used.
name The prefix to be used for each of the files resulting from the split operation. If no name argument is given, x will be used as the
prefix of the output files. The combined length of the basename of prefix and suffixlength cannot exceed NAME_MAX bytes. See
OPTIONS.
USAGE
See largefile(5) for the description of the behavior of split when encountering files greater than or equal to 2 Gbyte ( 2^31 bytes).
ENVIRONMENT VARIABLES
See environ(5) for descriptions of the following environment variables that affect the execution of split: LANG, LC_ALL, LC_CTYPE, LC_MES-
SAGES, and NLSPATH.
EXIT STATUS
The following exit values are returned:
0 Successful completion.
>0 An error occurred.
ATTRIBUTES
See attributes(5) for descriptions of the following attributes:
+-----------------------------+-----------------------------+
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
+-----------------------------+-----------------------------+
|Availability |SUNWesu |
+-----------------------------+-----------------------------+
|CSI |Enabled |
+-----------------------------+-----------------------------+
|Interface Stability |Committed |
+-----------------------------+-----------------------------+
|Standard |See standards(5). |
+-----------------------------+-----------------------------+
SEE ALSO
csplit(1), statvfs(2), attributes(5), environ(5), largefile(5), standards(5)
SunOS 5.11 16 Apr 1999 split(1)