Right now I have some troubles. I’m finding a way to solve one problem. I have some file in the tree whose names are stdout-captured, stderr-captured and status-capture and I have to rename these files to stdout-expected, stderr-expected and status-expected.
Thanks for your help.
Right now I have some troubles. I’m finding a way to solve one problem.
Share
From what we can discern of this question, you’re attempting to create a programmatic rule to rename files ending in extensions
stdout-captured,stderr-captured, andstatus-captured(assuming one typo) into files ending in extensionsstdout-expected,stderr-expected, andstatus-expected, respectively. Obviously, if each of these definitions is inclusive of exactly one file, a rotemvmay be more appropriate.To perform the translation you desire with
sed, simply invoke the following in/bin/bashwith the desired target as your current working directory:… where
$EXTENSIONand$REPLACEMENTare defined for each of the cases that you wish to detect and replace for. This assumes no files contain.$EXTENSIONanywhere in the remainder of the filename.awkis unnecessary for this solution.For invoking this recursively across multiple directories, consider replacing
lswithfindand updating the rule accordingly. Note thatfindhas its own facilities to perform operations on found resources, as well.