linux - Linux bash 中的多重重命名

标签 linux bash

我尝试使用此代码重命名我的文件(昨天日期)1、文件(昨天日期)2,3,4,5...。

#!/bin/bash
echo dir date?
read datedir
cd /mnt/c/Users/OPS\ 1/Desktop/F/CVS/CVS\ COMPONENTS/CVS$datedir
echo date now?
read datetd
echo last date?
read lastdate
rename -v 's/$lastdate/$datetd/g' *$lastdate

最佳答案

阅读man rename后,我明白你想要做什么:

您的rename命令使用错误。使用以下内容更新它:

rename "$lastdate" "$datetd" *$lastdate

SYNOPSIS: rename from to file...

DESCRIPTION: rename will rename the specified files by replacing the first occurrence of from in their name by to.

source: man rename

关于linux - Linux bash 中的多重重命名,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53203348/

相关文章:

c - Linux TCP 服务器,每 X 秒向几个客户端发送 RAW 数据

运行守护进程后找不到守护进程日志

linux - linux下如何在不注销/登录的情况下重启键盘输入法

linux - 如何检查一个文件是否是另一个文件的一部分?

c++ - 如何在 bazel/googletest 中使用环境变量

git - 用于检查 git 更改然后遍历更改文件的 Shell 脚本?

linux - 让 ./countdown 5 从 5 开始倒计时

bash - 解析 bash 中的 getopt

bash - bash vi 模式下 tmux 清除历史记录

linux - 在 RHEL 上安装 Postgresql 8.1.17 服务器