veda
veda

Reputation: 6584

Shell Script Error- can't execute the command

I wrote a bash shell script to rename the file,

#!/bin/bash

#renaming the files

for filename in 'find . -name "PostStackTemplate*"' 
do
   echo $filename 
   newName='echo $filename | sed -e "s/TestVersion/Version2/g" $filename'
   mv $filename  $newName 
done

When I execute this script, I am getting the output as

find . -name "PostStackTemplate*" 
mv: invalid option -- n 
Try `mv --help' for more information.

Am I doing something wrong.

Upvotes: 2

Views: 336

Answers (1)

jcollado
jcollado

Reputation: 40374

I think you to use command substitution to assign the output of the sed command to the newName variable:

newName=$(echo $filename | sed -e "s/TestVersion/Version2/g" $filename)

Otherwise, newName would contain just the string being assigned.

Upvotes: 2

Related Questions