Top "Grep" questions

grep is a command-line text-search utility originally written for Unix.

How can I search for a multiline pattern in a file?

I needed to find all the files that contained a specific string pattern. The first solution that comes to mind …

linux command-line grep find pcregrep
Using sed and grep/egrep to search and replace

I am using egrep -R followed by a regular expression containing about 10 unions, so like: .jpg | .png | .gif etc. This …

regex sed grep
How to do a non-greedy match in grep?

I want to grep the shortest match and the pattern should be something like: <car ... model=BMW ...> ... ... ... </…

regex shell command-line grep regex-greedy
How to search a specific value in all tables (PostgreSQL)?

Is it possible to search every column of every table for a particular value in PostgreSQL? A similar question is …

postgresql grep string-matching
How can I grep for a string that begins with a dash/hyphen?

I want to grep for the string that starts with a dash/hyphen, like -X, in a file, but it's …

unix grep escaping
Highlight text similar to grep, but don't filter out text

When using grep, it will highlight any text in a line with a match to your regular expression. What if …

linux grep command-line-interface
How can I find all of the distinct file extensions in a folder hierarchy?

On a Linux machine I would like to traverse a folder hierarchy and get a list of all of the …

linux grep filesystems file-extension
Parsing json and searching through it

I have this code import json from pprint import pprint json_data=open('bookmarks.json') jdata = json.load(json_data) …

python string json grep pprint
Remove empty lines in a text file via grep

FILE: hello world foo bar How can I remove all the empty new lines in this FILE? Output of command: …

linux grep text-processing
grep output to show only matching file

What is the option for grep that will allow me only to print the matching file and not the line …

grep