0

Under folder:

/var/userTN/applo folder

I have around ~100 shell scripts that include the following PATH:

GLOBAL_PATH=/export/pop/PLW5

I want to replace the PATH on all the scripts under folder:

/var/userTN/applo 

to this PATH

GLOBAL_PATH=/export/lld/sat

How to replace the PATH:

GLOBAL_PATH=/export/pop/PLW5

On all the files under folder:

/var/userTN/applo

With find + sed or other approach ? ( as Perl one liner solution )

remark:

Replace should be match exactly the “GLOBAL_PATH=/export/pop/PLW5

For example

The PATH -> GLOBAL_PATH=/export/pop/PLW51 ( should not replaced! )

1

Using sed:

sed -i.bak 's#^\(GLOBAL_PATH=/export/\)pop/PLW5$#\1lld/sat#' /var/userTN/applo/*

The original file(s) will be backup up with .bak extension, if you don't want backup(s):

sed -i 's#^\(GLOBAL_PATH=/export/\)pop/PLW5$#\1lld/sat#' /var/userTN/applo/*

Example:

$ sed 's#^\(GLOBAL_PATH=/export/\)pop/PLW5$#\1lld/sat#' <<<'GLOBAL_PATH=/export/pop/PLW5'
GLOBAL_PATH=/export/lld/sat

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.