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

learn more… | top users | synonyms

1
vote
1answer
95 views

Difference between 'grep' in Ubuntu and Kali Linux?

I always used the following command to filter out my contacts email addresses from a directory in Kali Linux: grep -rIhEo "\b[a-zA-Z0-9._-]+@[a-zA-Z0-9._-]+\.[a-zA-Z0-9._-]+\b" >> 1A I tried ...
4
votes
2answers
224 views

regex search works with `grep -E` but not with bash script?

I use the same regex with grep and it gives me a match but when doing it in a bash script, it return no match. Test String(part of the file testregex.txt): <a ...
1
vote
1answer
25 views

Searching for file contents on whole disk

I am trying to find my old IP address in config files in order to replace it by my new IP address. I found one answer that proposes the command sudo grep -HrnF '1.2.3.4' / to find those IP ...
2
votes
3answers
90 views

Search and print the lines from the output which can contain lines with errors

I have a command example, device list which gives me all devices with their status as okay or error in the following format [okay ]: you are listening on : 11 [error ]: not currently ...
-3
votes
0answers
78 views

Insert multiple lines into a file after specified pattern using bash shell scripting

I want to insert multiple lines into a file using shell script. Let us consider my input file contents are: input.txt: abcd accd cdef line web Now I have to insert four lines after the line ...
1
vote
2answers
38 views

how to trim dpkg upgraded packages list

Latest upgrade borked my system and I`m trying to revert the last upgrade. I opened my comp with live USB and chrooted to partition that is OS installed. I get the upgraded packages with cat ...
0
votes
1answer
48 views

grep keeps printing the same string

I typed grep ch->spl[4] * into my shell to look for something in a mud code and its broken grep now. Any time I try to grep anything pretty much it puts the spl[4] before the filename like this. ...
2
votes
3answers
292 views

Using grep to search texts with single quote?

I am using gedit text editor with embedded terminal in ubuntu 12.04. I'm trying to search for some text using grep. I want to search for this line of code 'type' => 'select' I tried: grep -r ...
1
vote
2answers
40 views

Find word that has more than 50 characters

I am trying to use find in combination with grep to find all the php files in my web server which have a word (any sequence of characters except whitespace) with more than 50 characters. I have this ...
0
votes
1answer
19 views

Use locate to find name in directories only

If i lost a file I use locate a lot. Works perfectly and with grep you can quickly find back what you looked for. However, often it generates a lot of output which is not always easy to filter. One ...
2
votes
1answer
71 views

omit filenames in grep

I am greping a string from multiple files, but the one undesired side effect, is the filename prefacing the output. How can I suppress the filename outputs using only grep? $ grep -i lp lpNet* ...
2
votes
2answers
29 views

Efficiently search sorted file

I have a large file containing one string on each line. I would like to be able to quickly determine if a string is in the file. Ideally, this would be done using a binary chop type algorithm. Some ...
1
vote
3answers
34 views

I have difficulties with regex to pull certain information from a data file

The data I am working with data that has this format: 1880 20 David 7570 Mabel 13096 I need to pull the year (1880), the rank (20), and the name only (David or Mabel). The end result is: ...
0
votes
1answer
105 views

sed, grep, and awk file sorting

I'm trying to get all the files which have 'load' in their names from a directory. I'm trying to do: find -type f | sed -s 'load However, I recurrently receive an error sed: -e expression #1, char ...
0
votes
0answers
42 views

Option for GREP only non-default processes and services?

is there any option for grep only non default processes and services? I know how show all of this and export to file, but manual reading and deleting line by line is not ideal. :-) Thanks for your ...
2
votes
1answer
251 views

Using Modifiers of Perl-compatible Regex (PCRE) in grep

According to grep --help and man grep, we can use the -P option in order to interpret the pattern as a Perl regular expression (PCRE, to be precise), instead of the default POSIX basic regular ...
1
vote
1answer
38 views

Assigning grep output to a variable

In a terminal I type: grep '<td><a href="http://www.blabla.cc' file.txt works fine. But if I type: var= `grep '<td><a href="http://www.blabla.cc' file.txt` I am unable to ...
0
votes
3answers
62 views

Why is my grep + regex not working?

I recently decided that enough was enough -- I was going to learn to use grep fluently. It's been all of three hours and I'm already stumped by this toy problem. I'm currently syncing a RAID5 array, ...
0
votes
0answers
38 views

i use grep file to search disk file but have many file doesn't exist alert

I use this command: sudo grep -R 'mode_t st_mode' but have many alerts that say many files do not exist. grep: /usr/share/pyshared/numpy/core/include/numpy/cfunc.h: do not have that file or ...
2
votes
2answers
254 views

grep stirght from a pcap file (no tcpdump)

I'm trying to figure out the correct command syntax. I have a pcap file, and I want to use grep, and grep only to take out all of the uniq ip addresses from without the file So assuming the file is ...
0
votes
1answer
138 views

how can i use grep to find IPV4 Number in a pcap file with regx syntac?

I'm new in ubuntu. I have this IP regex '\b((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\.|$)){4}\b' I have a network pcap file, I want to use this regex and the grep -e to find all IP address in the ...
0
votes
1answer
77 views

grep multiple files into one set of data

lets say i have few files which have structure like file1.txt apple fruit tomato vegetable file2.txt apple red green tomato green yellow is there a way to grep at once these 2 files (or more) ...
2
votes
1answer
61 views

grep on --help doesn't work on some commands

I just wondered why you can't grep on some --help commands. For example if I use ifconfig --help | grep unix it still prints the whole help instead of the line with unix. But on grep --help | grep ...
1
vote
3answers
142 views

Finding certain strings with grep (or similar)

I have two parts of a string that I know, called phrase1 and phrase2 that are in the same line of a file that occur multiple times throughout the file. I need to extract these lines from the file; ...
3
votes
1answer
88 views

Did grep change how it uses regexp?

I used to run commands like: find /dev | grep sd* to output a list of all the drives attached to my computer. It appears that I now have to add any random character before the star in order to get the ...
0
votes
1answer
28 views

how to always use rgrep with color

Replace grep command with grep -n --colour? is there anything similar for rgrep auto color?
1
vote
2answers
87 views

Problem with grep command

I have three files testx,testy and testz all in same directory Sikh. All three files contain same data or content. The contents are: aaabb Aaaaa AAAAA bbbcc Bbbbb BBBBB ff–ff Ccccc CCCCC ...
2
votes
3answers
3k views

What is the meaning of “ps -aef | grep $(pwd)” command?

What is the meaning of this command, what does it do? ps -aef | grep `pwd`
0
votes
1answer
45 views

Extract numerical value from string

I want to extract the numerical value out of the below command output : bash-3.2# psrinfo -pv | head -1 The physical processor has 1 virtual processor (0) That is, the output should be "1". Can ...
1
vote
1answer
137 views

pgrep pattern length limit

pgrep returns nothing if the pattern length is longer than 15 characters. I can't find anything in the man page about maximum pattern length. Is this a bug? for purposes of exposition I created a ...
0
votes
1answer
120 views

how to use grep to search for a word which can be followed and/or preceded by a non alphabetical character?

I want to search for javascript variables. So If my variable is geometry I want grep to return all lines like this e.g. geometry.property1 myfunc(geometry) etc.. but not these ...
13
votes
2answers
718 views

What is the difference between grep apple file and grep “apple” file?

What is the difference between grep apple file and grep "apple" file? What does putting the quotation marks do? They both appear to work and do the exact same thing (display same line).
0
votes
1answer
71 views

How would I display the lines that do not have certain letters? [duplicate]

How would I display the lines that do not contain certain letters? This is what I have already tried unsuccessfully to show the lines that do not consist of an a or b: egrep *[^ab]* filename
0
votes
1answer
241 views

How to use grep to search for a file anywhere

I'm finding that a script is getting started twice, so I want to search for the script name in any file anywhere, to see where its getting called. So I did this... cd / sudo grep -r autostart * ...
1
vote
3answers
7k views

What does 2>/dev/null means…?

I want one or two line description about the following command line: grep -i '\/support\/security\/bulletins\/' content 2>/dev/null
2
votes
5answers
1k views

What does the 'grep' command do?

I would like to learn how to use it so I can start to use the terminal more.
0
votes
2answers
174 views

Is grep syntax different from regex?

I want to extract name of removed packages from here "cat /var/log/dpkg.log | grep 'remove'" 2013-09-09 15:57:34 remove activity-log-manager:i386 0.9.4-0ubuntu6.2 <none> 2013-09-09 15:57:35 ...
2
votes
1answer
95 views

Split a variable line by line

I initialize variable like this: dmesgDevs=$(dmesg | grep idVendor) and want to print it line by line and then check if theres is word in particular line.
2
votes
3answers
2k views

Bash cut and grep commands through python

I've tried to read a txt file and find the lines which contain a certain word "checkout_revision". I want to find these lines one by one in a for loop and store them in my variable, let say temp. I ...
1
vote
1answer
347 views

Grep Regex match not returning result as expected

I have several Ubuntu servers and there is some behavior that has me curious. On any newly installed machine (Ubuntu Server 12.04.3 LTS), if I run: echo "testbla123" | grep -P -o [0-9]* This will ...
2
votes
3answers
865 views

how can one combine a series of grep statements piped together?

I would like to know if there is a way to combine a series of grep statements into one that works like this ./script I want output like this a b c not like this a c a b a b c a b c d ...
3
votes
2answers
1k views

How can I use grep to view only part of BFGMiner which is being run in screen over ssh?

Okay, bear with me on this. I'm using a program called BFGminer, which hopefully you know is a bitcoin mining program. Anyway. It updates every second a few lines that look like this: DEVICE 0: xxxx ...
0
votes
1answer
214 views

How to print the line number when searching for a string in multiple files

I would like to know a handy command to search for some strings in multiple plain text files and show the line number where it matchs in the output. ie: grep -r 'hello' --include=*.js ¿? output: ...
2
votes
2answers
2k views

Recursive grep fails for *.c files

I tried to recursively search a pattern in all the .c files in the following way > grep -lr search-pattern *.c But got this as the output > grep: *.c: No such file or directory When I use ...
1
vote
2answers
655 views

Avoid duplicate pids while grepping for a pattern

I have written a shell script that reads the updating logs and sends an email notification when there are OOM using do while loop. I am able to get the email notification for OOM errors but every ...
0
votes
1answer
51 views

Why are some OCRed pdfs greppable, and some aren't?

So let's say I have 10 files that are searchable using pdfgrep Of those, some are searchable using grep and some aren't Why's that? what's the trait that allows a pdf to be greppbale?
0
votes
1answer
42 views

Piping pdffonts to grep

So I want to use grep to list the filenames of pdfs that match the search string "Type 1C". grep is supposed to get the data from pdffonts, but when I execute this syntax it just executes pdffonts ...
1
vote
2answers
209 views

using egrep to find missing @ in log

I am using the following command to find log entries that are the result of a log in to the email server: egrep '_login[^ ]' /var/log/exim_mainlog That works fine to find entries that contain ...
1
vote
3answers
130 views

How to stop killing browser by terminal

I am using Ubuntu. my friend is killing my browser from his ubuntu machine using terminal. He knows my password. Do let me know any way to stop this killing process. I know that changing the password ...
0
votes
0answers
231 views

How do I search recursively for a phrase in odt files

I have a folder with subfolders in it and many libreoffice documents (.odt). I need to find in which one there's a particular phrase. I tried grep -ir "search phrase here" . but it only found the ...