Menu
Active3 months ago
In the linux shell, the following command will recursively search and replace all instances of 'this' with 'that' (I don't have a Linux shell in front of me, but it should do).
What will a similar command on OSX look like?
- How to Search for a Word or Phrase in a PDF Document. In this Article: Adobe Reader DC Google Chrome Browser Preview on Mac Community Q&A This wikiHow teaches you how to find a specific word or phrase in a PDF document using free Adobe Reader DC application or the Google Chrome browser for Mac and PC, or by using the Preview application on a Mac.
- In the linux shell, the following command will recursively search and replace all instances of 'this' with 'that' (I don't have a Linux shell in front of me, but it should do). -name '*.txt'.
46.8k2929 gold badges158158 silver badges223223 bronze badges
Nov 20, 2018 In XP under advanced search, I was able to type a word I was looking for in the word or phrase in the document box. For example, if I have 100 WordPerfect documents and I want to search for those that contain the name Jones, I used to be able to type it in the box and have it list those that contained that word.
JackJack
9,6381313 gold badges7979 silver badges148148 bronze badges
14 Answers
OS X uses a mix of BSD and GNU tools, so best always check the documentation (although I had it that
less
didn't even conform to the OS X manpage): sed takes the argument after
-i
as the extension for backups. Provide an empty string (-i '
) for no backups.The following should do:
LC_ALL=C find . -type f -name '*.txt' -exec sed -i ' s/this/that/ {} +
The
vitaut-type f
is just good practice; sed will complain if you give it a directory or so.-exec
is preferred over xargs
; you needn't bother with -print0
or anything.The {} +
at the end means that find
will append all results as arguments to one instance of the called command, instead of re-running it for each result. (One exception is when the maximal number of command-line arguments allowed by the OS is breached; in that case find
will run more than one instance.)24.1k1515 gold badges9696 silver badges164164 bronze badges
TaylanUBTaylanUB3,65011 gold badge1212 silver badges1515 bronze badges
For the mac, a more similar approach would be this:
WillWill1,87011 gold badge1515 silver badges2020 bronze badges
madxmadx4,35433 gold badges3838 silver badges4848 bronze badges
As an alternative solution, I'm using this one on Mac OSX 10.7.5
Credit goes to: Todd Cesere's answer
Maciej GurbanMaciej Gurban4,91933 gold badges2424 silver badges4545 bronze badges
eb80eb802,81944 gold badges1818 silver badges2828 bronze badges
A version that works on both Linux and Mac OS X (by adding the
-e
switch to sed
):vrocvroc
This is my workable one. https://solarhigh-power.weebly.com/excel-pie-chart-legend-too-small-text-excel-for-mac.html. on mac OS X 10.10.4
The above ones use find will change the files that do not contain the search text (add a new line at the file end), which is verbose.
NoteCodeNoteCode
If you are using a zsh terminal you're able to use wildcard magic:
sed -i ' 's/search/high-replace/g' *.txt
MentorMentor
Search For Text In Folder Of Document Mac
Whenever I type this command I always seem to hose it up, or forget a flag. I created a Gist on github based off of TaylanUB's answer that does a global find replace from the current directory. This is Mac OSX specific.
It's nice because now I just pop open a terminal then copy in:
curl -s https://gist.github.com/nateflink/9056302/raw/findreplaceosx.sh | bash -s 'find-a-url.com' 'replace-a-url.com'
You can get some weird byte sequence errors, so here is the full code:
Nate FlinkNate Flink3,49922 gold badges2525 silver badges1818 bronze badges
https://bitbucket.org/masonicboom/serp is a go utility (i.e. cross-platform), tested on OSX, that does recursive search-and-replace for text in files within a given directory, and confirms each replacement. It's new, so might be buggy.
Usage looks like: Transcribe audio to text for mac os 2017 lunex.
user4425237user4425237
user2725109user272510996422 gold badges1717 silver badges3535 bronze badges
I used this format - but..I found I had to run it three or more times to get it to actually change every instance which I found extremely strange. Running it once would change some in each file but not all. Running exactly the same string two-four times would catch all instances.
user1399145user1399145
Text editors for python. The command on OSX should be exactly the same as it is Unix under the pretty UI.
clopsHow To Search Text In Folder
clops2,64666 gold badges3232 silver badges4949 bronze badges
Samuel DevlinSamuel Devlin
Grep Text In Folder
protected by eyllanescSep 6 '18 at 1:43
Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).
Would you like to answer one of these unanswered questions instead?
Would you like to answer one of these unanswered questions instead?