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

learn more… | top users | synonyms

2
votes
1answer
90 views

copy several lines from one file to another

I would like to use grep in order to copy from one file to another all lines that are between lines /protein_id= untill the end of the protein sequence shown. For example, from this input: CDS ...
3
votes
3answers
54 views

Move pattern to beginning of line

I am trying to reformat a log file such that date and time appear at the beginning of the line. My logs look like this: blah, blah, blah, Friday, Mar 13,2015 16:59:42 yadi, yadi, yada, Friday, Mar ...
2
votes
2answers
198 views

Need a hand with a grep word command

Just getting the hang of Linux Command Line, but having trouble with grep commands. I'm trying to find out how many times a word appears in the last 1000 lines of a text file I have a feeling that ...
0
votes
1answer
35 views

How to I parse a file and only keep certain words?

Let's say I have a list of words I want to keep. list=['hi','name','first'] I want to be able to go through a text file, keep each and every word in my list, and output the new cleaned up content ...
3
votes
1answer
135 views

Use a list of words to grep in an other list

I've got a list with 250 lines in it. I have to run all of them through a web server to get a list of output. This list, however returns many more lines, than I'm interested in. Say, my list.txt is: ...
3
votes
5answers
301 views

Extract part of a line upto a particular string

Let us assume I have a file with lines like: /java/jdkxx/jvm_jdk/bin/opt /java/jre/jre_jvm/bin/opt /foo/bar/bin/other/stuff/here Is there a way I can extract part of the lines upto bin. I mean, ...
0
votes
2answers
26 views

Grep : Filtering Question

I need to construct a regular expression that will filter a group of words that begins and ends with the same word. For example, the life of the free will output the life of the and he was and he his ...
4
votes
4answers
539 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
24 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
58 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
102 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
120 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
12 views

Where is php.ini when I install APC?

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
42 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
71 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
41 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
51 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
151 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
40 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
50 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
113 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
49 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
160 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
112 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
59 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
56 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
51 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
62 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
57 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
95 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
1k 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
36 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
547 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
804 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
32 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
237 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
70 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
1k 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
114 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
63 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
130 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
146 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
56 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
75 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
46 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
56 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 ...
3
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
24 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 ...