linux - Remove prefix from a LIST of files in bash
问题描述
I have a list of files with a common name pattern, all with the same structure (prefix ave.
):
ave.20050716-12:00:00.stat_profiles.nc
ave.20050816-12:00:00.stat_profiles.nc
ave.20081116-00:00:00.stat_profiles.nc
ave.20120215-12:00:00.stat_profiles.nc
ave.19990316-12:00:00.stat_profiles.nc
ave.20020616-00:00:00.stat_profiles.nc
My question is: How do I remove ave.
from all the files in a file list / folder?
解决方案
You can use a for
loop and string substitution
for file in ave.*
do
mv "$file" "${file#ave.}"
done
This is just an example to get you started and you should check for things such as already existing files with the name without "ave.".
推荐阅读
- json - AWS API Gateway 将动态 JSON 直接写入 DynamoDB 并保持 JSON 结构
- network-programming - SNMP 协议 - 为什么我得到的值比我应该得到的多?
- c - 当我尝试访问字符串数组时出现分段错误
- ignite - Apache Ignite - 使用 Map 类型的字段存储和搜索对象的最佳方法是什么
> - flutter - 我如何在 Dio Package 中得到错误响应
- swift - SKAudioNode 缓冲音频
- testing - Truffle testing - 尝试使用 web3 测试 EIP712,有没有其他选择?
- python - 如果任何值大于 x,则 Pandas 减去 x 与多个数据框不同的列名
- spring-boot - 在 org.springframework.amqp.core.Message 类中使用 HttpHeaders
- java - Spring Data JDBC 一对多关系导致大量日志警告