Back to problems
COMP2041
21T2 Q7 — Print rename-with-extension commands
For each filename argument print exactly one line (do not rename anything):
- has a
.→# <f> already has an extension - no
#!first line →# <f> does not have a #! line #!line has none ofpython/perl/sh→# <f> no extension for #! line- the target
<f><ext>already exists →# <f><ext> already exists - otherwise →
mv <f> <f><ext>(.py/.pl/.shfrompython/perl/shin the#!line).
POSIX shell only (#!/bin/dash); standard UNIX filters; no awk, Perl, C or Python. From COMP2041/9044 21T2 Final.
Samples
stdin
expected
# script.rs already has an extension # script1 does not have a #! line # script2 no extension for #! line mv script3 script3.py mv script4 script4.pl mv script5 script5.sh
shell
14