返回题目列表
COMP2041
21T2 Q7 — 打印加扩展名的重命名命令
对每个文件名参数恰好打印一行(不真正重命名):
- 含
.→# <f> already has an extension - 首行非
#!→# <f> does not have a #! line #!行不含python/perl/sh→# <f> no extension for #! line- 目标
<f><ext>已存在 →# <f><ext> already exists - 否则 →
mv <f> <f><ext>(按#!行中的python/perl/sh取.py/.pl/.sh)。
POSIX shell only (#!/bin/dash); standard UNIX filters; no awk, Perl, C or Python. From COMP2041/9044 21T2 Final.
样例
stdin
期望输出
# 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