Question: implement the command chunk to divide a large file (filename.txt) into files of 1,000 lines each. At the UNIX shell prompt, your command should accept

implement the command chunk to divide a large file (filename.txt) into files of 1,000 lines each. At the UNIX shell prompt, your command should accept either:

 chunk [options] -f filename.txt [-p prefix] [-s suffix] chunk [options] [-p prefix] < filename.txt

[options] in square brackets indicates that the command recognizes both excluding [options], or including options. The options modifies the size of output of the files, as follows.

-l line_count ---- Creates smaller files of line_count lines in length (instead of the default of 1,000 lines). -w word_count ---- Creates smaller files of line_count lines in length (instead of the default of 1,000 lines). -c character_count ---- Creates smaller files of line_count lines in length (instead of the default of 1,000 lines). .

The chunk command will give each output file it creates the name prefix with a extension or suffix tacked to the end that indicates its order. By default, the chunk command should use 2 character alphabetical suffixes: ----- aa to the first output file, ----- bb to the second output file, proceeding through the alphabet to ----- zz for subsequent files.

If the user prefers numberic:

-s suffix ---- Creates a 2 digit character numeric suffix, with starting number indicated by the suffix, so that if suffix -is 00, then chunk will generate:

----- 00 to the first output file, ----- 01 to the second output file, proceeding through the alphabet to ----- 01 for subsequent files. -p prefix ---- If a prefix is not indicated, the default prefix will be x.

EXIT STATUS The chunk utility exits 0 on success, and >0 if an error occurs.

Example:

chunk -l 100 -f maria.txt -p part- -s 00

Here chunk divides file maria.txt to new files named part-00, part-01, part02, ... that are each 100 lines long, except possibly the last file that may be less than 100 lines long.

chunk -w 100 -f maria.txt -p part- -s 00

Here chunk divides file maria.txt to new files named part-00, part-01, part02, ... that are each 100 words, except possibly for the last file that may be less than 100 words long.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!