Skip to content
Advertisement

Tag: grep

Grep Regex: How to find multiple area codes in phone number?

I have a file: each line consist of a name, room number, house address, phone number. I want to search for the lines that have the area codes of either 404 or 202. I did “(404)|(202)” but it also gives me lines that had the numbers in the phone number in general instead of from area code, example: I do

Access the word in the file with grep

I have a conf file and I use grep to access the data in this file but not a very useful method for me. How can I just get the main word by search-term? I using: Print: I want: (without “export: “) How can I do that? Answer If you’re using GNU grep you can use PCRE and a lookbehind:

grep string after first occurrence of numbers

How do I get a string after the first occurrence of a number? For example, I have a file with multiple lines: I want to get the following output: Thank you. Answer Imagine the following two input files : A quick solution with awk would be : This line substitutes the first string of anything that does not contain a

Regex is not checking some part of text

I’ve example file with data to analyze by egrep command: My regexp looks that: I wan’t to find only rows where [RM# {digits}] AND [IG# {digits}] but it returns like using OR and results looks following: Expected output is Answer Looks like you want to search for a line that should match two different strings in any order.. one way

How to grep recursively and ignore subdirectories of subdirectories?

I am already familiar with grep -r “searchTerm” . and I am familiar with grep -r “searchTerm” exclude={subdir1, subdir2} . However, I am looking for a way to grep recursively, through subdirectories and ignore certain subdirectories of subdirectories. For example, if the directory structure is as follows: How would I be able to exclude idc and otherStuffIdc, since these folders

How to skip multiple directories when doing a find

I’ve written a find function that searches for a string in each file in a given path, while skipping a list of directory names that I don’t want searched. I’ve placed this script in my .bashrc file to be called like so: The find portion works great, and it colorizes the search text so that it visually stands out!, but

egrep two identical numbers and two identical letters n times

Hi I’ve been having trouble with the command egrep. Here is my question: Lets just say I was running in a for loop on these words: I only want to print the word if it has two identical numbers and two identical letters and the word repeats itself. for example in this case the only words that should print are:

Search output of p4 command

I am trying to perform an action depending on the output of perforce commands. But it seems that pipping and greping/acking the command doesn’t appear to pickup the output e.g. Further example of what i’m trying to do: Is there anyway to read the output of a perforce command without having to write to a file then read the output?

Finding repeated names in a file

Hi i have a txt file with last name and name of people, now i want do use egrep to only display the names of the people with the same last name. I have no idea how i could do this. Thanks for help my txt looks like this: and the output should be: I’ve currently tried running: …but this

Advertisement