Introduction
For this assignment, you will use awk to create a program for summarizing and printing information based on the directory listing data of files and information.
You are not to use any other programs, utilities, or scripting languages not covered in class, unless
otherwise specifically and explicitly stated in this document.
Your program should take the output from the modified ls command line seen below, and process
the data in order to output the aggregate information:
ls - la -- time - style ='+%Y/%m/%d %H:%M:%S'
In fact, to avoid human error and ensure you are always using the correct command line, I suggest
creating and adding new alias to your bash resource configuration file:
alias lsa ="\ls -la --time - style = '+%Y/%m/%d %H:%M:%S'"
Note that the inclusion of the leading backslash ensures no other previously-defined/existing ls aliases are used; certain other options such as -h could cause your script to fail, for example.
Aggregated information requirements
The aggregated information processed from the directory listing data should consist of each of the following, when applicable, in the order specified below (see the input/output example further below for an example of proper output formatting):
Per-user grouping of file-related counts found in specified directories
– Username of the entity owning these files
– Total number of directories found that are owned by this user
– Total number of files found owned by this user, printing three values:
∗ All files
∗ Hidden files
∗ “Other” files found that are owned by this user
(these items include, but are not limited to, symbolic links, FIFO’s, character or block devices, etc. Basically, anything that is not a regular file nor a directory will fall under this category)
– Total file storage (in bytes) occupied by this user’s regular files.
• Itemization of the oldest and newest regular files found (if no regular files exist in the listing, simply report "None" for these items. If only one regular file exists, it is reasonable to report this file as both the oldest and newest.)
Also note, if multiple files share the same oldest or newest time stamps, you can break the tie however, you wish; there are no guidelines you must adhere to while doing so.
• Total file-related counts found in the specified directories
– Total users owning files within these paths
– Total number of files found, printing two values: all files versus hidden files
– Total number of directories found
– Total number of “other” files found
(these items include, but are not limited to, symbolic links, FIFO’s, character or block devices, etc. Basically, anything that is not a regular file nor a directory will fall under
this category)
– Total file storage (in bytes) occupied by all regular files listed.
Note: again, do not use sed , Python, or any other languages or utilities not explicitly allowed by
this assignment.
Note 2: ensure to test the processing of ls listings for multiple directories, rather than just one. Such listings can be generated by passing more than one directory to ls and/or by the simple addition of the -R recursive option to the custom ls command shown previously. Two examples of such command lines can be seen here:
ls - la -- time - style ='+%Y/%m/%d %H:%M:%S' dir1 dir2 dir3
ls - laR -- time - style ='+%Y/%m/%d %H:%M:%S' dir1
or if you have defined the aforementioned alias, equivalently:
lsa dir1 dir2 dir3 file1 dir4
lsa -R dir1 file1 dir2
Note that these commands can also include filenames alongside the directory names on the command line as well; this is perfectly permissible and should be accounted for, hence why it was shown in the example above.
Example
The example execution provided below is an excerpt from the following command, executed using
the provided example input file:
ssilvestro@fox05: /courses/cs/3423/Summer20/assign3$ ./assign3.bash <
data/input.txt
Alternatively, the script could be executed as follows on any arbitrary directory using the specified
ls command:
ls -la –time-style='+%Y/%m/%d %H:%M:%S' ~ | ./assign3.bash
Example Input Data
ssilvestro@fox05: /courses/cs/3423/Summer20/assign3$ head -n 30 data/input.txt
Extra Credit (200% / n)
A 200% bonus will be awarded for those whose script correctly and properly sorts the username-
the grouped portion of the output based on the total computed storage space for each user (use the
“Storage” field for this number), displayed in ascending order of their total storage size (i.e. users with the largest storage consumption will appear first). Break ties alphabetically (e.g. many users will consume zero storage space due to “other” files and directories not contributing to the file count; only regular files contribute).
Once again, n represents the number of students who completed this extra credit portion correctly,
in its entirety. No points will be awarded for partial credit; this feature must function properly, as described, in order to be eligible for these extra bonuses.
Assignment Data
A few sample input files can be found at the following location on the fox servers, however it is imperative that you fabricate many of your own examples to ensure that your script functions according to the specifications outlined above:
/usr/local/courses/ssilvestro/cs3423/Summer20/assign3.
Script Files
Your submission should consist of exactly two files:
assign3.bash - a bash script used as the driver program for your awk script
assign3.awk - the awk program used in assign3.bash
Script Execution
Your program should each be invoked through a single bash file with input taken from either standard
input, or an arbitrary set of filenames specified on the command line, as shown below.
In addition to the above Assignment Data, your program should also work with arbitrary input from the ls -la –time-style='+%Y/%m/%d %H:%M:%S' command defined on page 1. This includes both reading from one or more named input files, as well as accepting piped or redirected input
directly into standard input, as in these examples:
ls - la -- time - style ='+%Y/%m/%d %H:%M:%S' ~ | ./ assign3 . bash
– or –
./ assign3 . bash listing . txt [ listing2 . txt [...]]
– or –
./ assign3 . bash < listing . txt
Submission
Turn your assignment in via Blackboard. Your zip file, named a3-abc123.zip with your personal abc123 should contain only your two bash and awk files.
If you attempt the extra credit, name your file a3-abc123_EC.zip. Without the _EC, your submission will be graded as normal.
Are you looking for Web Programming Assignment Help? Codersarts web developer experts offer the best quality web programming, coding or web programming Tutors. Get Web Assignment Help at an affordable price from the best professional tutors Assignment Help. Order now at get 15% off.
If you have project or assignment files, You can send at contact@codersarts.com directly