Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

UNIX 1) (6 points) The following shell script mySplit is used to split a large file into multiple smaller files on every n lines. The

UNIX

image text in transcribed

1) (6 points) The following shell script mySplit is used to split a large file into multiple smaller files on every n lines. The filename of new file is created by putting an index (starting from 1) after the original filename. When running the shell script, the first argument should be the pathname of the file to be split, the second argument should be the value of n For example, file test (in current working directory) has 150 lines, after running command below, two new files test1 and test2 are generated in current working directory. test1 has the first 100 lines from test, while test 2 has the remained 50 lines SmySplit test 100 #1 /bin/bash # Get the number of lines in the given file lineCount= | awk 'print $1" # The index of new file starts from 1 newFileIndex-l; # A new file starts from line n1 n1-1i while Snl lineCount ] do n2=expr $n1 + $2-1" # The new file ends with line n2 # Extract multiple lines from the given file into the new file sed -n " # Updat the start line number for next file newFileIndex-exr

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Demystifying Databases A Hands On Guide For Database Management

Authors: Shiva Sukula

1st Edition

8170005345, 978-8170005346

More Books

Students also viewed these Databases questions

Question

1 2 6 .

Answered: 1 week ago

Question

Understand how to design effective service guarantees.

Answered: 1 week ago