hi,
i would like to substitute a substring with the given string in filanames. I wrote this script that use awk:
USAGE: subFlNmPart "file*more*csv" "more" "all"
OUTPUT: file1_more.csv -> file1_all.csv for example
I am not sure why $o is not assigned. Any ideas?
k.
i would like to substitute a substring with the given string in filanames. I wrote this script that use awk:
Code:
function subFlNmPart(){
for i in `find -name "$1" -print`; do
bn="$(basename $i)";
#eval o=\"$( awk -v inFl=$bn -v target=$2 -v word=$3 'BEGIN{
sub(target, word, inFl);
print inFl}' )\";
o=`awk -v inFl=$bn -v target=$2 -v word=$3 'BEGIN{
sub(target, word, inFl);
print inFl }'`;
echo $o;
done
}
USAGE: subFlNmPart "file*more*csv" "more" "all"
OUTPUT: file1_more.csv -> file1_all.csv for example
I am not sure why $o is not assigned. Any ideas?
k.