regex - Replace string in filename in bash -
so have function
ren_barrow(){ file in *.clu mv -f $file ${file//release/"$1"} done }
but when run this, can see everyfile ends in .clu renamed.
i want put if statement around mv
says if filename contains release in carry on. if not have if statement errors saying
cannot rename: $file , $file same file.
ren_barrow(){ file in *.clu # if $file grep "release"; mv -f $file ${file//release/"$1"} # fi done }
you can have mv
command this:
[[ "$file" != *"release"* ]] && mv -f "$file" "${file//release/$1}"
Comments
Post a Comment