I am making a script to relocate a project file. I have all of the variables in place and everything is working except:
Quote:
sed -i.bak -e "s/$NFP/${NFPN}/" $ARCHIVEPATH/Script/${FILE}_renamed.nk
the first variable changes everytime it passes thru a loop. The second is a constant value.
when I run that it does what I want...but incorrectly. It is finding results that contain the current string....but sometimes the result is incorrect.
If the current string is
this/is/a/directory/here
and I need it to be
that/isnt/the/path/here
and it comes across
this/is/a/directory/and/more
it will change
this/is/a/directory/and/more
to
that/isnt/the/path/and/more
I don't want that. I only want it to change it if it matches 100%
I have tried:
Quote:
sed -i.bak -e s/$NFP$/${NFPN}/ $ARCHIVEPATH/Script/${FILE}_renamed.nk
it doesn't change anything
Quote:
sed -i.bak -e 's/'$NFP'/'${NFPN}''/' $ARCHIVEPATH/Script/${FILE}_renamed.nk
and
Quote:
sed -i.bak -e 's/'$NFP'/'${NFPN}''/g' $ARCHIVEPATH/Script/${FILE}_renamed.nk
with the same result.
I can not find a single function that will work!
my variables are all written out as
\/this\/is\/a\/directory btw, so that isn't the problem.
If anyone knows another solution to this I would REALLY appreciate it! I am not stuck on sed. It's just the only way I know to do this.
---------- Post updated at 07:35 PM ---------- Previous update was at 06:53 PM ----------
I seem to be having the same issues with perl
---------- Post updated at 07:37 PM ---------- Previous update was at 07:35 PM ----------
perl seems to be a lot faster tho