Posted By: Anonymous
I am trying to use
grep to match lines that contain two different strings. I have tried the following but this matches lines that contain either string1 or string2 which not what I want.
grep 'string1|string2' filename
So how do I match with
grep only the lines that contain both strings?
You can use
grep 'string1' filename | grep 'string2'
grep 'string1.*string2|string2.*string1' filename
Answered By: Anonymous
- AppCompat v7 r21 returning error in values.xml?
- Swift: How to get substring from start to last index…
- Raku vs. Perl5, an unexpected result
- What are the undocumented features and limitations…
- Append String in Swift
- How to prevent scrolling the whole page?
- YAML Multi-Line Arrays
- Java regular expression OR operator
- How can I resolve Web Component Testing error?
- What is your most productive shortcut with Vim?
- Getting the closest string match
- trouble shoot a creating a mySQL function for…
- How to use Regular Expressions (Regex) in Microsoft…
- How to check if a string contains only digits in Java
- Flex: REJECT rejects one character at a time?
- Using sed to split a string with a delimiter
- How to capture a word boundary in Swift NSRegularExpression?
- Uncaught (in promise) TypeError: states.filter is…
- How to implement Quasar q-table with server-side pagination?
- C# Convert List to Dictionary
- What is the difference between re.search and re.match?
- How to get integer values from a string in Python?
- Checkout another branch when there are uncommitted…
- How to get the part of a file after the first line…
- template repeat in template repeat
- Different return type for function factory typescript
- Text File Parsing and convert to JSON?
- Reference - What does this regex mean?
- How to concatenate two strings in SQL Server 2005
- Windows recursive grep command-line
- custom text position on ipywidgets button
- How to grep (search) committed code in the Git history
- regex match any single character (one character only)
- Fast way of finding lines in one file that are not…
- How to grep for two words existing on the same line?
- create pascol voc xml from csv
- List(of String) or Array or ArrayList
- Easiest way to ignore blank lines when reading a…
- How do SO_REUSEADDR and SO_REUSEPORT differ?
- How to return concatenated string in C
- OpenCV Object detection with Feature Detection and…
- Difference between matches() and find() in Java Regex
- Get the list of String from a HTTP response in JAVA
- Why is it that "No HTTP resource was found that…
- Colorized grep -- viewing the entire file with…
- One to many relationship in two JSON arrays, lookup…
- How to create an object property from a variable…
- How do I get hour and minutes from NSDate?
- How to match letters only using java regex, matches method?
- How can I exclude all "permission denied" messages…
- Identifier is undefined
- grep --ignore-case --only
- Remove dataframe row containing a specific in a list…
- Set the filename for file download with use of Fetch()
- SQLSTATE[HY093]: Invalid parameter number: parameter…
- What is an optional value in Swift?
- Find and kill a process in one line using bash and regex
- Setting up and using Meld as your git difftool and mergetool
- How to search in an array with preg_match?
- conflicting types error when compiling c program using gcc
- Using PHP to upload file and add the path to MySQL database
- appcompat-v7:21.0.0': No resource found that matches…
- XPath to return only elements containing the text,…
- How to grep for contents after pattern?
- Get the index of a certain value in an array in PHP
- how can i account for repeats in a checker function…
- Match linebreaks - n or rn?
- How do you grep a file and get the next 5 lines
- shell script. how to extract string using regular…
- You modified *** twice in a single render
- PHP parse/syntax errors; and how to solve them
- How to extract string following a pattern with grep,…
- Convert multiple csv to another csv format
- C++ Need help sorting a 2D string array
- How do I create a multiline Python string with…
- Capturing Groups From a Grep RegEx
- Count number of occurrences of a pattern in a file…
- Regex to find all placeholder occurrences in text
- Arduino error: does not name a type?
- How to test if string exists in file with Bash?
- How do I do a case-insensitive string comparison?
- How to delete all records in a model's hasMany…
- Design DFA accepting binary strings divisible by a…
- VBA for filtering columns
- Avoid creating new session on each axios request laravel
- Vue.js $set not updating the display
- PHP recursive function not allowing page to load
- Swift extract regex matches
- Regular expression to find two strings anywhere in input
- how to get text from textview
- How do I test to see if a line of a .txt exists or…
- grep regex whitespace behavior
- Working with strings in C, strcat and the strange…
- How to use '-prune' option of 'find' in sh?
- Ukkonen's suffix tree algorithm in plain English
- Scanner is skipping nextLine() after using next() or…
- regex.test V.S. string.match to know if a string…
- how to fix Invalid request (Unsupported SSL request)…