I would like to run
grep
on Mac OS X that would meeting the following criteria:
- With a bit of practice, you'll be using grep and regular expressions to find anything you want. Kirk McElhearn is the author of The Mac OS X Command Line: Unix Under the Hood (Sybex, 2004).
- What tools (except grep) you. Stack Exchange Network Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.
- FastGREP is a search and replace tool for Windows.You could use regex or wildcards to find. Replace them too. It works so fast than Windows Explorer search or other tools. (1)Fast and easy-use. (2)PCRE regular expressions supported.
Active3 years, 7 months ago
- search all files with
*.R
or*.r
as extension and ignore other files - Find strings:
wordA
andwordB
accounting for the fact that the strings may appear in the formatsomeRubbishWordARubbish
(this is a valid match) - List only the files where both strings appear irrespectively of the order
- Print the lines where the strings appear
- Highlight the found words in colour
- Print the file name as a header and lines under the header. I'm inspired by the
ack
options. - Ignoring the case
I was thinking of making use of this discussion and starting with the following
grep
syntax:
Then combining it with the following:
However, I would appreciate comments on ensuring that all of the criteria stated above will be evaluated correctly.
I wanted a free grep tool for Windows that allowed you to right click on a folder and do a regex search of every file - without any nag screen. The following is a quick solution based on. AJC Grep - 1.3: AJC Grep is a powerful file finder, text search, replace and data extraction program for Windows. Tools to query oracle database. This is a major time saving tool for developers, documenters, web designers and anyone who has to search and replace in a large number of files.
Groups
Ack
Running
ack -f
shows that *.R
files would be searched so solutions using ack
will be accepted. For example, running:
gets the desired results with respect to the wordA. I was thinking of combining it the solutions discussed here but I would like to use AND not OR and ignore the order in which strings may appear. I further tried:
But this produced only the results for
wordB
.
Grep Regex Replace
Community♦
KonradKonrad
8,42810 gold badges59 silver badges110 bronze badges
2 Answers
Here's a script that combines the closely-named
awk
and ack
commands:
The awk command..
- Lists only the files where both strings appear irrespectively of the order
- Ignores the case
![Log analyzer tool Log analyzer tool](https://docs.fluentd.org/images/kibana4-screenshot.png)
..and the ack command..
- Prints the lines where the strings appear
- Highlights the found words in colour
- Prints the file name as a header and lines under the header inspired by the ack options
- Ignores the case
The awk script sets flags if there are search string matches. If both strings have been matched, then the snippet
exit !(sawWordA && sawWordB)
Hydra tool for mac. will return 0. Mac select series tool box for sale. If awk returns 0, then the ack command runs.
The ack
--nofilter
option tells ack to avoid reading from STDIN. Otherwise, ack would try to use the STDIN that the read
command is using.
In the comments, Konrad asked how to use the above code when passing in variables in a shell script. Below is an example: https://newrhino.weebly.com/blog/aqw-hack-tool-for-mac.
The above example doesn't escape any special characters in the arguments provided to the script. If escaping is needed, the script can be modified as needed.
Chad NouisChad Nouis
5,7081 gold badge22 silver badges27 bronze badges
Grep Regex Linux
Well, this is pretty inefficient, but assuming you aren't searching a large directory, this should work.
Regex Performance Analyzer
PapaBuduiitPapaBuduiit