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
, and status-captured
(assuming one typo) into files ending in extensions stdout-expected
, stderr-expected
, and status-expected
, respectively. Obviously, if each of these definitions is inclusive of exactly one file, a rote mv
may be more appropriate.
To perform the translation you desire with sed
, simply invoke the following in /bin/bash
with the desired target as your current working directory:
EXTENSION=stdout-captured
REPLACEMENT=stdout-expected
for arg in $(ls *.$EXTENSION); \
do mv $arg $(echo $arg | sed s/\\.$EXTENSION/.$REPLACEMENT/); \
done
… where $EXTENSION
and $REPLACEMENT
are defined for each of the cases that you wish to detect and replace for. This assumes no files contain .$EXTENSION
anywhere in the remainder of the filename. awk
is unnecessary for this solution.
For invoking this recursively across multiple directories, consider replacing ls
with find
and updating the rule accordingly. Note that find
has its own facilities to perform operations on found resources, as well.
solved Some troubles with using sed and awk [closed]