← 返回题目列表
UNSW 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.