Unix中的bash脚本 - Sed。未知代码

时间:2021-02-24 22:24:25
OLDEND = one 
NEWEND = two 
for FILE in *.$OLDEND 
  do 
    NEWNAME = `echo "$FILE" | sed -e "s/${OLDEND}\$/$NEWEND/"` 
    mv "$FILE" "$NEWNAME"
 done

I got this from a past exam paper and the questions just asked what it means. Can anyone help me out... I've an exam in 2 days and I'm trying to know all previous exams before I go in.

我从过去的试卷中得到了这个,问题只是问了它的含义。任何人都可以帮助我...我在2天内参加考试,并且在进入之前我正在尝试了解所有之前的考试。

1 个解决方案

#1


1  

  1. find all files in current directory matching <basename>.one
  2. 查找当前目录中与 .one匹配的所有文件
  3. with each file, rename to <basename>.two
  4. 对于每个文件,重命名为 .two

However, as has been noted, it will fail. Should be OLDEND=one

但是,正如已经指出的那样,它将失败。应该是OLDEND = 1

#1


1  

  1. find all files in current directory matching <basename>.one
  2. 查找当前目录中与 .one匹配的所有文件
  3. with each file, rename to <basename>.two
  4. 对于每个文件,重命名为 .two

However, as has been noted, it will fail. Should be OLDEND=one

但是,正如已经指出的那样,它将失败。应该是OLDEND = 1