Need help writing Scripts


#1

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

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

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

etc.

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

im a bit of a noob but i think "sudo apt autoremove " will clean up the empty files the second idea you have sounds cool but i have no idea how to write scripts … You may possibly find assistance in the git hub community . they have a setup to write apps n stuff as a group ,and lots of new things are being created there daily