0% found this document useful (0 votes)
10 views1 page

Homework - Linux1 - Script-1

Uploaded by

Melissa Lemus
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views1 page

Homework - Linux1 - Script-1

Uploaded by

Melissa Lemus
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Linux-1, First Script, homework assignment

Create a simple basic bash-script, DIRLIST.SH for creating a tekst-file (DIRLIST.txt), containing the
content of a directory on the file-system.
The scipts must be controllable by the first argument when started, the file must be written in /tmp.
Output in the tekst file (also the direcory listing) must be in uppercase:

Example:

./ DIRLIST.SH /var/log

By starting the script, a file will be created (/tmp/DIRLIST.txt)


Inside the file DIRLIST.txt will a file-count on the first line, containing also the (variable) name of the
direcory which was scanned and counted:

THE DIRECTORY /VAR/LOG CONTAINS 89 FILES


BELOW IS THE DIRECTORY LIST IN UPPERCASE:

MESSAGES
DMESG
AUTH.LOG
BOOT.LOG
..
..

In the comment of your script must be the name of the author(s), and student number, class,
version/revision of the script.

Example of the first lines:

#!/bin/bash

#Ver 1.1
#Created by Yuri van der List / 1124556 / [email protected]
# Direcotory-listing script
# This script creates a directory listing and file count for any directory that is used when starting
this script.
# none bugs, It crashes when the directory-name is missing or incorrect, I had no time to fix this
# Variables used: counter: calculated number of files
………

Please use variables if you can, and add comment in the code. Describe the variables if possible in
comment like i did with one off them above.
Tip: make your script executable: chmod u+x DIRLIST.SH
Email your script as an attachment, as a zipped-tar-file (DIRLIST.tgz) which must be runeable(!), and
well tested, as a zipped tar-ball, to: [email protected]

Bonuspoints: Add input validation if you have time and energie left, so I cannot break the script.
If you work in groups (4 persons max), put all the names and studentnumbers in the comment

You might also like