I have a set of files with the following filename structure:
aa_bbbbb_cccccccc_dddddd.txt
I want to replace the third element cccccccc
with the value of the variable value
which I extract from the content of the file.
The values of the 4 components of the filename change, so I cannot replace using string replacement, but I need to replace based on the position of the substring I want to replace.
Any suggestion how to approach this using bash script only?
I cannot use rename. It does not seem to work in cygwin and, in any case, I cannot use string replacement. If we consider the "_" as a separator, I need to replace the third field with the value contained in a variable.
sed
, norename
, nomv
? – terdon Jan 18 '23 at 17:15