Question: All scripts should be placed in the bin / directory, in the user account s home directory. As a convenience, this directory is included in

All scripts should be placed in the bin/ directory, in the user accounts home directory. As a convenience,
this directory is included in the users PATH. Scripts should have exactly the specified filename, and note that
only those files will be submitted, so your scripts will need to be self contained.
There are several test files in directories audio/ and playlists/ that may be helpful for testing scripts,
and examples are given below to clarify how your scripts should work. However, students are encouraged to
thoroughly test each script on other files before submitting (the TA will use other files to test your scripts).
5 catm3u.sh
Write a Bash script named cat_m3u, sh that takes one or more M3U-format playlist files as arguments, and
displays the duration, title, and artist information for each track, and the total duration for the playlist.
5.1 Input format
The script output should be based on the #EXTINF lines in the playlist files, which will always have the form
#EXTINF : seconds, trackinfo
where seconds is an integer and trackinfo is the remaining characters on the line. Your script should handle
MSU text files where line feeds may be indicated by a line-feed character (LF, or '\
^(2)), a carriage-return
character ( CR , or '\\r^(')'), or a carriage-return character followed by a line-feed character. The playlists/
directory has examples of each.
5.2 Output format
For each #EXTINF: line in an input playlist file, the script should write an output line containing a duration,
followed by two spaces, followed by the track information (usually the title and artist). After reading the
entire input file, the script should display a separator line containing 8 : = characters, followed by two
spaces, followed by 50^(2=>) characters. Then, the script should display the total duration of the playlist,
followed by two spaces, followed by the input file name with directory information stripped off. Finally, the
script should display a blank line.
Each duration should be right justified, take up exactly eight spaces, and have the form
3loti: ss
for durations under one hour, otherwise
h: man: ss
for durations of one hour or longer. You may assume that there will be no duration that exceeds 99 hours.
In the above, "h" indicates the number of hours, "sunn" indicates the number of minutes, and "ss" indicates
the number of seconds, in a typical clock format: seconds are between 0 and 59 and always displayed as two
digits, minutes are between 0 and 59 and are displayed as one digit if and only if the duration is less than
ten minutes. hours are between 1 and 99(because they are not displayed when 0) and are displayed as one
digit if and only if the duration is less than ten hours.
5.3 Error handling
An appropriate error message should be displayed if the script is invoked with no command-line arguments.
An appropriate error message should be displayed for any input pathname that does not exist. All error
messages should be written to standard error.
5.4 Examples
user* cat_n3u,sh
Usage: cat_m3u.sh file file ...
user $ pwd
/home/user
user$ cat_m3u.sh playlists/B* playlists/C* playlists/D*> list.txt
Couldn't find playlist playlists/C*, skipping...
user$ cat list.txt
3:59 Brandenburg 1, first movement - Joharn Sebastian Bach
4:05 Brandenburg 1, second movement - Joharn Sebastian Bach
4:25 Brandenburg 1, third movement - Joharn Sebastian Bach
7:29 Brandenburg 1, fourth movement - Johann Sebastian Bach
5:37 Brandenburg 2, first movement - Joharn Sebastian Bach
4:28 Brandenburg 2, second movement - Joharn Sebastian Bach
3:30 Brandenburg 2, third movement - Johann Sebastian Bach
6:36 Brandenburg 3, first movement - Joharn Sebastian Bach
0:13 Brandenburg 3, second movement - Joharn Sebastian Bach
3:25 Brandenburg 3, third movement - Johann Sebastian Bach
7:35 Brandenburg 4, first movement - Joharn Sebastian Bach
2:49 Brandenburg 4, second movement - Johann Sebastian Bach
5:23 Brandenburg 4, third movement - Johann Sebastian Bach
9:58 Brandenburg 5, first movement - Joharn Sebastian Bach
5:58 Brandenburg 5, second movement - Johann Sebastian Bach
5:38 Brandenburg 5, third movement - Joharn Sebastian Bach
7:10 Brandenburg 6, first movement - Johann Sebastian Bach
4:32 Brandenburg 6, second movement - Johann Sebastian Bach
6:12 Brandenburg 6, third movement - Joharn Sebastian Bach
1:39:02 Bach,3m3u
All scripts should be placed in the bin /

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!