I need to copy files and rename them.
replacing the “N” with another string that I have in an environment variable.
For the following file;
myFile_N_something.cfc_
I can do this with a for/do/done block, in a bash script using regex;
<code>for files in *.cfc_;
do
cp "$files" "${files/_N_/_$theID_}";
done
</code>
<code>for files in *.cfc_;
do
cp "$files" "${files/_N_/_$theID_}";
done
</code>
for files in *.cfc_;
do
cp "$files" "${files/_N_/_$theID_}";
done
BUT…
I also need to strip out the trailing “_” from the very end of the filename, too, so it ultimately ends up being;
myFile_32_something.cfc
(assuming i have “32” in the environment variable)
I can of course do another separate step… But I am hoping to “UP” my regex skills and do it in one command, if it is possible.
As always thanks!