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

learn more… | top users | synonyms

-1
votes
1answer
40 views

Reg ex - awk - grep from getline result [on hold]

I have a expr in awk, but I can't grep the result echo 34100 | awk '{expr $1 / 33.7 | getline result;}' -> sh: 1: 1009.89: not found the calculation is ok but I need to have the 1009.89. Could ...
0
votes
0answers
29 views

Cannot get grep and perl to work

It should work everthing is in data and it should be turning up results, i've had it working before so it must just be so syntax thing I'm not noticing. I can't get this work. I'm almost certain it's ...
1
vote
3answers
82 views

How can I extract pdf names from an lftp log file?

I have a log like this : 2016-05-11 07:09:54 ftp://test@test.dyndns.info/test1/fool/1999/How/05%20May/test160511.pdf -> /test/keep/more/use/05/test160511.pdf 0-28442281 33.5 KiB/s i need to ...
2
votes
1answer
31 views

Check whether I have a certain ppa

How do I check whether I already have a certain ppa in my list? How do I search through my list of ppas?
-1
votes
1answer
47 views

Help with “grep” command in terminal [closed]

I ran a command on a terminal in Ubuntu: $ grep "Director" file.lst And the output of that command was 1006|Pankaj | Director|sales|03/09/38|6700 I want know the full description of the output ...
0
votes
0answers
14 views

Pgrep command not found

I am using pgrep -f unit_test_01 and I am getting "-sh: pgrep: command not found" Any idea what am I missing here?
1
vote
3answers
3k views

Using Grep to get specific entries and ignore others

is there a way to use grep to ignore lines with 141.8. .. contained in them BUT get lines that have GET? Right now I have this but I must be doing something wrong sudo grep -v '^141.8.83.213' ...
1
vote
1answer
604 views

How to find a specific text in files with specific extension?

Let's say I'm searching for all files with .log extension that contain the text of abc. When searching for files with any extension would look like (Ref.: http://unix.stackexchange.com/a/16140/38353 ...
0
votes
2answers
45 views

Trouble with Shell Script cat | grep

#!/bin/bash mylanip=$(hostname -I | awk '{print $1}') touch /opt/portmapper/0prelims echo `java -jar /opt/portmapper/portmapper.jar -list | grep $mylanip > /opt/portmapper/0prelims` # HTTPS ...
4
votes
3answers
275 views

grep command for a text file in multiple directories

I have 24 directories in a specific directory (main_directory). Each 24 directory have a text file whose name is DATA.txt. I need to use grep command to extract below specific pattern for each text ...
0
votes
2answers
61 views

Check if input string exists in file

You must read string1, what should I do? Here's my code: #!/bin/sh echo "Enter your sting: " read read string1 if [ grep -q $string1 file.txt ];then echo "Found it" else echo "Sorry this string ...
0
votes
1answer
43 views

grep halts at files with no extension

I am running a command to search certain string in a folder but it halts when it encounters file with no extension. sudo grep -rlvF "peter.dickson@" /var/www how I can overcome this? As per the ...
1
vote
1answer
40 views

How can I build a scrollable, colored syslog viewer with less, ccze, grep?

I'd like to view logfiles with colored output, scrollable and searchable. How do I do that? I tried less /var/log/syslog | ccze | grep error, but it is not scrollable.
1
vote
1answer
46 views

how to list file names when searching for strings passed by cat with pipe

I want to search for a string in the files in a directory like: cat /etc/pam.d/* | grep pam_ck_connector.so but I also want to list the file names in which files the string pam_ck_connector.so ...
3
votes
3answers
407 views

What does a leading asterisk mean in extended and basic regular expressions?

What are the semantics of * at the beginning of a RE? It is documented (man 7 regex) that for basic REs it matches only * (i.e., it turns to an ordinary character), but what happens for extended REs? ...
0
votes
1answer
43 views

How to list file names with a total of X letters

Say I have a list of the following files in my current dir: lab1.jav mytst2 pie.c prog2.c tst3.ex tst5:5.tlab2jav lab2jav.ext new.c prog1.c tst1 tst4.exc tst6:6123.tA7-tst.c ...
8
votes
5answers
665 views

I need help with Grep to start at a section

I have some text files that I want to grep a section of code from. The goal I am trying to achieve is to start the view at a certain line & then be able to read anything below it. For example. In ...
0
votes
2answers
37 views

what's wrong with my grep command?

Grep works when I use is with ls | but when I try the command by itself, it just gives me a blinking cursor that never goes away on the next line (as if it's running a command). For example, I tried: ...
0
votes
1answer
41 views

Why the “service --status-all | grep mysql” get many unrelated result?

It seems weird here while running service --status-all | grep mysql why I get so many wrong result? It works fine on Centos where i am getting: mysql is running xxxxxxx This is what i am ...
0
votes
0answers
9 views

Checking two process in same port [duplicate]

I'm new to ubuntu and not have an expereince in networking so i have problem with binding port that already in use I checked it by sudo lsof -i tcp | grep LISTEN and got pid of the port to check ...
0
votes
0answers
58 views

`grep -r` command leads to kernel panic

Every time I run grep -r something . in vim command line mode, the system shows kernel panic message. And if I run it outside vim, the system totally freezes. I can do nothing. Even Ctrl-Alt F1-F12 ...
0
votes
1answer
19 views

Ubuntu grepping strings with missing spaces

let's say I had the email test1234test@test.com in a file which contains a list of emails. But, instead of having the entire email, I only had (for example) t**********t@test.com How would I grep ...
3
votes
1answer
1k views

proper syntax for grep: search a string, copy two rows above and transpose

Am new (2 days old) to Linux and grep and am stuck here. Scenario. I have data lasting more than 10yrs which I have been doing manually until I came across grep. The folders are of form \yyyy\mm\dd ie ...
4
votes
3answers
1k views

Difference in two types of command that uses grep

So, here we have two commands: cat /var/log/dpkg.log | grep " \install\ " cat /var/log/dpkg.log | grep install Why are the outputs of these commands different? And can you please explain the first ...
0
votes
1answer
325 views

search using regular expression with alternation

I'd like to search files containing G Bush, J Bush, B Bush, or H Bush The following command can achieve the goal: grep -rnE "G Bush|J Bush|B Bush|H Bush" Can we do something like grep -rnE ...
6
votes
4answers
1k views

How to escape “.” with sed or grep?

I have file with denm.xyz denm.abc denm.def denm_xyz denm_abc denm_def I want to extract the ones with . in it. I tried grep "denm\.*" file grep 'denm\.*' file sed "/denm\.*/p" file sed ...
0
votes
0answers
193 views

Freezes on restart and shutdown

Just installed Ubuntu 14.04, on Razer Blade 14 The system freezes as soon as I try to restart or shutdown. Tried to add 'pci' and 'acpi' and 'boot' to the grep, didn't help. Tried to reinstall, didn't ...
1
vote
1answer
284 views

How to search String with “\” character and to Replace it

I am Stuck into an issue regarding searching and replacing a directory path included in my thousands of file, what I want, to search those directory path in files and to replace it with new directory ...
0
votes
0answers
1k views

Log Sifting: Rewrite Logs for Human-Readable Verbage

My goal is simply to build a reworded log containing the lines where an external IP address interacted with an apache2 server. So far, I have come up with the following: #!/bin/bash # apache2 log ...
4
votes
1answer
918 views

Search files content for possible BTC key strings

I have 4 BTC addresses on two of my drives that I cant bloody find. I saved them under stupid name so they would be hard to find if someone had access to my system. Now I cant find them. Is there a ...
7
votes
3answers
822 views

Listing files with grep?

I have a directory that contains the following files: file1a file1ab file12A2 file1Ab file1ab I want to list all files that start with file1 and followed by two letter at most! The solution I ...
3
votes
3answers
6k views

Extract word from string using grep/sed/awk

I have a string 00:28:04 /usr/lib/jvm/jre/bin/java -DJDBC_CONNECTION_STRING= -Dspring.profiles.active=qa -XX:MaxPermSize=256 and want to extract the word qa that follows -Dspring.profiles.active. ...
5
votes
2answers
3k views

What does grep do?

Here is the description of grep from GNU.org: grep searches input files for lines containing a match to a given pattern list. When it finds a match in a line, it copies the line to standard output ...
10
votes
4answers
1k views

grep command and [ ]

I'm learning bash code and today I'm studying the command grep. if I run $ ps -fU user | grep thunderbird terminal shows: user 17410 1 0 10:09 ? 00:00:20 ...
0
votes
1answer
777 views

Why is grep only returning one line?

#!/bin/bash while true; do trap break SIGINT ping -w 5 10.0.0.1 | { trap '' SIGQUIT ts '%Y-%m-%d %H:%M:%S |' | grep -E 'PING|packets|rtt' | { read grep_out echo ...
10
votes
4answers
1k views

How would you count every occurrence of a term in all files in the current directory?

How would you count every occurrence of a term in all files in the current directory? - and subdirectories(?) I've read that to do this you would use grep; what is the exact command? Also, is it ...
0
votes
1answer
1k views

grep command to find 'words' that begin and end with * (e.g., *way*, *then*)

My original thinking was that this would work grep -w '\*.*\*' /path/file-name This produces some good hits but it doesn't respect the word option. I get whole lines. For example, like this ...
1
vote
1answer
64 views

Advanced Ping Script [closed]

I want to have a little script which do a ping to 8.8.8.8 every 2 seconds and put only out the time. It should also put a "#" between every time. Like this: 25.5 # 25.4 # and so on... Finally i ...
5
votes
3answers
667 views

How can I use the grep command to extract line which is the next line of greping line?

I have text file like (the specific part of the whole file); ! lat long elev (m) ! 44.5199005 11.6468000 50.4276 I need to extract second line and save ...
2
votes
2answers
226 views

Command to write all .js files to a single file?

I am trying to put all .js files in a directory and sub directories into a single file in lexical order. I have tried: grep -r --include=*.js * > dir/.filename What did I do wrong?
1
vote
2answers
52 views

Generate a log of all the installs on a system (whether apt-get/yum/pip/npm/…)

Is there a command (or specific syntax for history command) that generates (to screen or file) a log of all the installs on a system (whether they were through apt-get/yum/pip/npm/...). If possible, ...
2
votes
1answer
64 views

can you solve this? [closed]

if you have a puzzle and you want to solve it with computer... 6 characters the available characters is "NQAECFCYCPHY" what is the possible right words can you get? I tried to solve it with grep ...
16
votes
3answers
3k views

tail a log file but show only specific lines

I'm tailing a log file with -f flag. Then I'm piping this to grep, to find only lines that contain "X". That's working perfectly fine. Now I want to pipe this again into another grep, that will remove ...
1
vote
2answers
216 views

How to prevent grep from printing the same string multiple times?

If I grep a file containing the following: These are words These are words These are words These are words ...for the word These, it will print the string These are words four times. How can I ...
2
votes
3answers
2k views

Grep: The asterisk(*) doesn't always work

If I grep a document that contains the following: ThisExampleString ...for the expression This*String or *String, nothing is returned. However, This* returns the above line as expected. Whether the ...
1
vote
2answers
82 views

Can rm -rf use grep?

I am trying to use PlayOnLinux to install iTunes but my wine is clogged up, so I want to 100% delete the wine files, so is there any way to delete all files with the tag (or word) wine in them? ...
0
votes
2answers
46 views

Greping text file

I have text file: Line1 aaa Line2 aaa Line3 aaa Line4 importan info about Linux Line5 infoA Line6 infoB Line7 I would like to display line containing word "Linux" and two lines more. Regarding ...
0
votes
2answers
157 views

How to use output of grep for ping

I desperately try to use the output of grep for a script: ping dc"$(grep -o .""\[12].domain.local"" /etc/squid3/squid.conf)" ping "$(grep -o ""dc0\[12].domain.local"" /etc/squid3/squid.conf)" Both ...
0
votes
1answer
25 views

Compare and count in ubuntu

I have a file with 2 columns like this: Product Cost ab 5 ab 7 bl 1 bl 8 ce 4 I want to search for "ab" and "bl" and then need to sum up the Costs for them and ...
-6
votes
2answers
58 views

Getting number of users depending on their age [closed]

I have a text file in which there are two columns: Name Age Ashko 32 Mohan 45 arun 21 I want to get the number of users whose age is greater than 25 ex 2 in above case