grep is a command-line utility that is used for searching text.

learn more… | top users | synonyms

4
votes
4answers
262 views

Grep searching two words in a line

I've been trying to find a way to filter a line that has the word "lemon" and "rice" in it using a regular expression. I know how to find lemon or rice but not the two of them. They don't need to be ...
0
votes
1answer
13 views

grep single pattern having more than one matches

I have a file (X.txt) with a list of unique entries. I would like to use this file to grep from another File Y.txt which contain more than one entries for single pattern of X.txt. X.txt contains: ...
-1
votes
3answers
47 views

grep — list file name where match is found

I have a bunch of .html files in a directory. I want to look through each file and match a pattern (MD5). All of that is easy enough. The problem is I need to know what file the match was found in. ...
1
vote
2answers
90 views

Grep strings in a subgroup of lines in txt file

I have a file that looks like this AAA_21 PF13304.1 x_00004 AAA_22 PF13401.1 x_00004 SMC_N PF02463.14 x_00004 AAA_29 PF13555.1 x_00004 ...
-2
votes
1answer
60 views

How to combine ls and grep to list only files and using ls to count dirs

I have some troubles with combining ls and grep. The thing is that I have to use only ls and grep to list all files in home directory. Ive tried multiple of combinatnions but with no effect. I think i ...
0
votes
0answers
10 views

Errors during APC installation on Ubuntu 12.04

I am trying to install APC on Ubuntu 12.04, I faced some problems. I used this link: http://www.inmotionhosting.com/support/website/php-configuration/install-apc-for-php I then solved all the ...
0
votes
1answer
33 views

Match Pattern and write following value as variable

I'm trying to match a pattern and then pull the following information to create a file using that variable. Example (my data may look like either of the 2 examples) "headers": { ...
2
votes
1answer
51 views

grep - highlight inside a highlight

I'm facing difficulties while trying to multicolor-highlight matches using grep's color environment. After I stumbled across Colored grep, I found it very useful to highlight multiple pattern in a ...
1
vote
1answer
35 views

put multiple matches on one line to a new line using grep

I need to put multiple matches on a line each on a new line example: grep "banana" This is the output Apple banana orange banana lemon melon banana grapes apple banana I want to become: ...
0
votes
1answer
45 views

What does 'history | grep cp -r ' do?

I typed this commands by mistake in my shell and then my shell was filled with all the text . I don't know what it does .Please someone explain it to me .
1
vote
1answer
139 views

Using 'grep' and other utilities

I know this is a seemingly peculiar question, but I want to have a better understanding of using Linux utilities so I'm going to ask for something that seems rather complicated to me to understand the ...
0
votes
0answers
34 views

How to dump selected iwconfig outputs to text files? (to analyse Tx-power, bit rate, link quality, etc. for EMF reduction)

BACKGROUND I've read about Electromagnetic Field (EMF) pollution and I want to protect myself. I have a not bad solution for my smartphone, now decided to tackle WiFi. It appears that power of the ...
0
votes
2answers
37 views

When using grep on html files, how can I display only the text and not the tags?

I have wgot a large website. Rather than setting up a local search engine I use grep to search the site. Grep's output shows the html (of course), but I only want to see the text (and not all the html ...
4
votes
2answers
96 views

Remove all English text and leave Arabic text

This question is a lot like this. I just need a slight modification. I have a csv file that looks like this y(document).ready(function($) { $('#wp_mep_2').mediaelementplayer({ m:1 ...
0
votes
0answers
42 views

Killing every root process over a certain pid

I want to kill every process that is root and not mine. Now there's: sudo pkill -u root But... Well, it kind of, I don't know, MAKES THE WHOLE COMPUTER TO CRASH. So, I need a way to kill every root ...
1
vote
1answer
93 views

cat vs grep vs awk command get the file content which one is more efficient and less time consuming?

Lets say I have file content like this: this is a simple file for testing purpose with few lines in it. to check the cat and grep command to verfy which is best and less excution time consuming ...
0
votes
1answer
19 views

Using grep with regex

I have a regex which works fine for me. I checked it on following site: https://www.regex101.com/ (?<=.log:)[^;]* Unfortunately it doesn't work anymore when I try to use it with grep. I try to ...
1
vote
1answer
63 views

What does grep line buffering do?

Here's my command that I'm using in a script to grep real-time data. It doesn't seem to pull real-time data correctly as it just misses some lines. tail -f <file> | fgrep "string" | sed ...
0
votes
2answers
45 views

Using Grep to search for multiple words in a file

I want to use grep in an If statement to search for a first-name and last-name within a text file. I can't seem to make it work on my own. if [[ grep -E "$first|$last" Datafile.txt ]] then ...
0
votes
2answers
55 views

problem with grep

I was wondering why I get the following output when searching for files with the command: $ grep -l prac * allprac grep: Desktop: Is a directory grep: Documents: Is a directory grep: Downloads: Is a ...
0
votes
3answers
44 views

Using grep to print line numbers

I would like to use the grep command to print a line number for the string I'm searching for. However, when I used the command grep -n it prints the line number with a colon : next to it. Is there ...
0
votes
1answer
56 views

How to create the vertical line [Pipe]

I am new to Ubuntu and i want to know how to create the vertical line that's Pipe in ubuntu 14.10
0
votes
1answer
47 views

Trying to organize files by extension using a script (grep, for, foreach, find), but I'm overwhelmed. Looking for advice [duplicate]

I want to iterate through all files in the Source directory and stick them into the Dest directory. Example list of files: /source/folder/text.txt /source/folder/document.pdf ...
0
votes
2answers
65 views

grep to get compile error

I have created a simple c program and have left off a ';' on purpose to get an error. I want using the grep command to know whether the compilation was successful or not. I use: gcc test.c | grep ...
2
votes
1answer
908 views

How do I grep for multiple patterns on multiple lines?

To be precise Some text begin Some text goes here. end Some more text and I want to extract entire block that starts from "begin" till "end". with awk we can do like awk '/begin/,/end/' text. How ...
0
votes
1answer
35 views

Grep for specfic number format

I have a Unix script, which within has release numbers which are like this (2.19.0.32) Look like IP's but are not as some are like this 2.23.0.06.DBP. I've tried variations of this but comes back ...
6
votes
3answers
506 views

How to grep lines, based on a certain pattern?

Let's say I have a file containing following two lines: 2014-05-05 09:11:53 /aa/bbbb/cccccc 29899 2014-05-05 09:12:17 /aa/bbbb/cccccc?dddddddd 16767 I need to get ...
4
votes
4answers
629 views

How to find all patterns between two characters?

I'm trying to find all patterns between a pair of double quotes. Let say I have a file with contents look like as following: first matched is "One". the second is here"Two " and here are in second ...
1
vote
1answer
27 views

'Grotty' man page messages

If I try to search within certain man pages using grep, I get several 'grotty' messages. For example: man mpv | grep dvdnav results in: mpv dvdnav://[longest|menu|title][/device] [options] ...
1
vote
2answers
176 views

grep recursively for specific files

I tried to use grep to find some code snippets in python files which are spreaded over some directories / subdirectories, but unfortunately my attempts failed :( I thought: grep -r "search-pattern" ...
0
votes
1answer
68 views

Locate two variable strings and write one as a file [closed]

I have a text document that contains 2 lines of information. Line 1 contains a filename, and line 2 contains an reference ID. The document contains additional strings other than the desired ...
1
vote
2answers
761 views

How to grep for groups of n digits, but no more than n?

I'm learning Linux, and I have a challenge that I seem to fail to solve on my own. Here it is: grep a line from a file which contains 4 numbers in a row but not more than 4. I'm not sure how to ...
0
votes
2answers
93 views

Copy a word from the html file of a web page using shell script

I am trying to write a shell script which should crawl into a web page and fetch a particular character/phrase from its html and display it. Particular character means, for example if the html of the ...
-6
votes
1answer
57 views

using grep or any of its variations

Write a regular expression to match a proper IP address. IP address has this format: x.x.x.x , where x is any number in the range of 0 to 255. e.g. 192.168.0.1 10.100.0.3
3
votes
1answer
123 views

Find a file which contains a string and delete it in Ubuntu

My CMS is full of SPAM scripts and they are almost in every folder. I figured out, that I can find those scripts by using this find/grep command: sudo find . -type f \( -name '*.php' -or -name ...
1
vote
1answer
134 views

What environment does xargs pass to grep?

I am trying to search for two strings in a file. This is the command that I am using grep -l -r ads2gas | xargs grep vp8 For some reasdon the second grep is not working correctly. I am getting "no ...
0
votes
2answers
26 views

Grep searching for words by letter

I'm searching through a file of people that is structured like below John Smith 555-555-5555 Harvard Square, Boston I'm interested in finding all the LAST names that start with the a certain ...
0
votes
2answers
42 views

Grep printing a line that doesn't contain a set of numbers

I'm trying to get Grep to print all lines in a txt file that do not contain the numbers 834. When I try "grep [^834] file.txt" it still prints all the lines containing 834 but just doesn't highlight ...
-2
votes
3answers
73 views

How to grep keywords with unique value? [closed]

I just want data those have unique value, say we write log file for mobile users <mobile_number1>|20141006 06:15:26||AKQY6LYACZAA4O|12|3|BIHAR| <mobile_number2>|20141006 ...
0
votes
3answers
44 views

What's the easiest way to list files of a given extension, save that list to a text file, but omitting the actual extensions when in the text file?

This is for a counterstrike server, where mapcycle.txt contains all the maps found in the maps/ folder, but the list of maps must not contain the .bsp extension. Example of maps/ folder: map1.bsp ...
0
votes
1answer
47 views

Explain in details egrep line

Hi i found in the internet egrep line. The line founds the longest line in the text. But i dont understand specific elements. Maybe someone could explain me all line? Here it is: egrep -n "^.{$(wc -L ...
2
votes
6answers
1k views

How to command grep not to display the searched string? [duplicate]

I want to print a part of a line in a file. The whole line looks like this. Path=fy2tbaj8.default-1404984419419 I want to print only the characters after Path=. I have tried grep Path filename | ...
1
vote
0answers
20 views

How to get previously install package information?

Is there a way using dpkg, apt, logs, or any thing else, where I can query/retrieve previously installed versions of an application? I don't care about which previous versions were available up to the ...
2
votes
1answer
219 views

'grep' command not working on Lubuntu

I'm using Lubuntu 14.04 with a fresh install (Monday) and I noticed that my grep command doesn't work. Whatever I do, it shows me the grep usage page. For instance, if I try to run: grep test * or ...
0
votes
1answer
448 views

Return only line number, if pattern 'Exist' and 'Not Exist'. using 'grep' command

I have this sample file for my input: xyxxyx xyxx xxyx yxyy yxyx xxyxxx xx xyx xxx x y x xxyy yxxy xyxxy xxy y x y xyxy xyx yyxx xyyxyxy xyx yxyy xyy yxyx xxyxyyx And I tried to find only "xyx" ...
2
votes
2answers
155 views

append a word to the end of a line in txt file

I have a file that should have "OK" at the end of a certain line the line that should be modified is the first line not ending with "OK" I can grep the file to get the line to be modified using ...
0
votes
0answers
24 views

How do I djvubind on ls and grep result?

How do I djvubind only files that are in ls | grep -P "page\\d\\d\\d.tif"?
4
votes
3answers
444 views

Searching for patterns in csv files

I have file.csv that looks like this 4,6,18,23,26 5,12,19,29,31 2,5,13,16,30 9,10,24,27,32 4,5,10,19,22 4,6,8,10,25 2,3,4,25,11 I want to find some patterns and save them in another log file ...
0
votes
1answer
233 views

Linux : Data extraction from text file

I have a text file in which thousands of data is there. eg. id=row_value profile=row_value name=row_value email=row_value address=row_value id=row_value2 profile=row_value2 name=row_value2 ...
19
votes
3answers
1k views

Saving output of a grep into a file with colors

I need to save the result of a grep command into a file, but I also want the output file to be formatted and keep the colors just like in the terminal. Is there a way to do that? Maybe make grep save ...