Purchase Linux CDs / DVDs / Flash Drives at OSDisc.com

Welcome to Our Community

While Linux.org has been around for a while, we recently changed management and had to purge most of the content (including users). If you signed up before April 23rd, 2017 please sign up again. Thanks!

  1. More ways to get the info! - we shoot all of our new original content out as well as random messages on Twitter and our newsletter!. Twitter | Newsletter
    Dismiss Notice

Need help writing Scripts

Discussion in 'General Linux' started by Id10t, Dec 5, 2018.

  1. Id10t

    Id10t New Member

    Nov 4, 2018
    Likes Received:
    Once again I would appreciate some help writing scripts, I need 2 of them. The first:

    Write a script to remove any empty files (i.e., files with size 0) from directory that is specfied by the user on the command line. The name of the script should be cleanUp. This script should take either 0 or 1 command-line-arguments. If 1 argument is provided, then it is the name of the directory to be cleaned. If no argument is provided, then the script should clean the current-working-directory.

    Your script must check that the command-line is valid. The script should output an error message if 2 or more arguments are provided, or if the single argument is not a directory.

    The second:

    Some files, such as video files, can be very large. Some systems have a limit on the size of any file that can be transmitted by email, or by ftp. To get around such a limit, we could take any large file and break it up into smaller pieces.

    Write a script, called fragment, that takes exactly two command line arguments. The first argument should be an integer, which will be a line-count. The second argument should a filename.

    Your script should NOT alter or destroy the given file, but should create several smaller files by breaking the original file into pieces. Each of the smaller files will contain line-count lines from the original file. For example, if line-count is 3 and the filename is foobar, then your script should create:

    a file called foobar1 which contains lines 1-3 from foobar

    (Log in to hide this advertisement)

    a file called foobar2 which contains lines 4-6 from foobar

    a file called foobar3 which contains lines 7-9 from foobar


    Your script must also check that the command-line is valid. The script should output an error message if the number of command-line-arguments is not 2.

    Thanks in advance to anyone one that can help.
  2. arochester

    arochester Moderator
    Staff Member Gold Supporter

    Apr 25, 2017
    Likes Received:
    This looks like homework/an assignment.

    Please do not ask people to write scripts for you from scratch.

    YOU need to write the scripts and tell us what you have done and what the outcome is.

    We will try to help you with what you have done --- but doing it for you is another thing.
    wizardfromoz and Rob like this.

Share This Page