I
I
Igor Kramarov2019-06-08 01:57:28
macOS
Igor Kramarov, 2019-06-08 01:57:28

How to find and replace text on a remote computer, Mac OS Mojave?

what I want? - find and change the text - you need to replace the phone numbers on the hosting, in more than 30 site files in the index.html files
, what is there? - ssh connection between Mac OS Mojave to Mac OS Mojave. one laptop and one Hackintosh with a Mac axis for a web server I
try
find Users/Desktop/Documents \( -type d -name .git -prune \) -o -type f -print0 | xargs -0 sed -i 's/OldText/NewText/g'
sed: 1: "/Users/Desk ...": command i expects \ followed by text
but it gives an error command i expects \ followed by text - something is missing and the command will not be executed. I want to change the content inside a specific folder of a specific site in order to change contacts there, in fact, in the content of the file. how, for example, - find and replace In sublima text, but to a remote host via ssh? I want to edit from the command line. If anyone knows how to do this, I would be grateful for the hint.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
J
jcmvbkbc, 2019-06-08
@jcmvbkbc

sed -i

-iis not described in POSIX, which means it may work differently on different systems.
sed -i.random-backup-tag 's/OldText/NewText/g'should help. Then delete the backups with the command
find  Users/Desktop/Documents \
    -type d -name .git -prune -o 
    -type f -name '*.random-backup-tag' -print0 | \
    xargs -0 rm -f

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question