N
N
nixischev2014-02-25 14:49:54
linux
nixischev, 2014-02-25 14:49:54

How to implement escaping slashes for ex?

Good day!
The problem is the following - you need to replace the string 'usr/local' in the file with a variable (another way), while the search template and the replacement template need to be changed (if I understand correctly) - escape the slashes, here is my code:

#!/bin/bash
BASEDIR=$(cd "$(dirname "$0")"; pwd)
FIND='/usr/local'
REPLACE=$BASEDIR/php
ex -vc '%s/$FIND/$REPLACE/g|x' $BASEDIR/Makefile

Help me please!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
leclecovich, 2014-02-25
@nixischev

For this, I used sed, but the essence is the same. For gray hair, the expression will look like this:
And, correctly noted, slashes must be escaped, i.e.
FIND='\/usr\/local'

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question