Assignment 6



Nov 2
45 pts
Nov 19

Create a shell script which takes two command line options, a stem and an extension. It then renames every (non-hidden) file in the current directory having the expecified extension with a name of the following form:

where exten is the specified extension and stem the specified stem, and NNNN is a four-digit count starting from 1. For instance:
[bennet@desktop test]$ ls Makefile asst2.html asst4.html index.m4 alvin.txt boris.txt missing_parts.txt asst1.html asst3.html asst5.html elwood.pdf [bennet@desktop test]$ web html [bennet@desktop test]$ ls Makefile boris.txt missing_parts.txt web_0004.html alvin.txt web_0001.html web_0005.html elwood.pdf web_0002.html index.m4 web_0003.html [bennet@desktop test]$ src in [bennet@desktop test]$ ls Makefile index.m4 web_0004.html alvin.txt missing_parts.txt web_0001.html web_0005.html boris.txt web_0002.html elwood.pdf web_0003.html [bennet@desktop test]$

Hint: The Unix printf command can be used to pad a number to a given width. For instance, printf "%04d" 16 will print 0016, without a newline. If you keep a counter in a shell variable N, then $(printf "%04d" $N) will generate the padded number as part of a command, or on the right side of a variable assignment

Once you have created your files, send them to me here. If you create it on Sandbox, you can copy it off using WinSCP, FileZilla or any client that supports the scp protocol. Or just run this from Sandbox: