如何复制动态文件名并在复制到UNIX中的其他目录时附加一些字符串 [英] how to copy the dynamic file name and append some string while copying into other directory in unix
本文介绍了如何复制动态文件名并在复制到UNIX中的其他目录时附加一些字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有很多文件,例如 ABC_Timestamp.txt
, RAM_Timestamp.txt
,这里的时间戳每次都不同.我想将此文件复制到其他目录,但是在复制时,我想在文件末尾附加一个字符串,因此格式为 ABC_Timestamp.txt.OK
和 RAM_Timestamp.txt.OK
.如何在动态文件中附加字符串.请提出建议.
I have many files like ABC_Timestamp.txt
, RAM_Timestamp.txt
here timestamp will be different everytime. I want to copy this file into other directory but while copying I want append one string at the end of the file , so the format will be ABC_Timestamp.txt.OK
and RAM_Timestamp.txt.OK
. How to append the string in dynamic file. Please suggest.
推荐答案
您可以说:
for i in *.txt; do cp "${i}" targetdirectory/"${i}".OK ; done
或
for i in ABC_*.txt RAM_*.txt; do cp "${i}" targetdirectory/"${i}".OK ; done
这篇关于如何复制动态文件名并在复制到UNIX中的其他目录时附加一些字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文