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

learn more… | top users | synonyms

0
votes
0answers
28 views

lsof: WARNING: can't stat() fuse.gvfsd-fuse file system /run/user/1000/gvfs Output information may be incomplete

I am using this command sudo lsof | grep mongod | grep TCP it shows record but first it shows below warning i am guesing its not showing me the whole list of open connection lsof: WARNING: can't ...
0
votes
0answers
46 views

Extract data from logfile from only the previous 24 hours, with bash in a shell script

Using the Ubuntu 14.04 trusty and transmission log for the log file. What is the best way to extract the last 24 hours of log entry's? I have attempted using sed awk grep I cannot seem to get the ...
4
votes
3answers
560 views

ps aux | grep with a dot

I'm trying to write a script which greps for a running process. I'm trying to avoid the actual grep from coming back from the ps aux output. However I'm getting varying results if I use a dot or not:...
0
votes
2answers
34 views

Grep code explanation

In a file weather.xml, there is the string temp="103". I run this command grep -o "temp=\"[^\"]*\"" ~/.cache/weather.xml The output is 103. What does [^\"] mean? Thanks
1
vote
1answer
26 views

Unsure of grep output because of bash wildcards

I am trying to get a better understanding of bash commands. ls /usr/include/ | grep \.h It is supposed to list all the files ending in .h (C libraries) but it outputs more than expected. ...
3
votes
0answers
36 views

How to find the last valid information possibly spread over several log files

I have a fleet of busses that send me a monitoring log file every morning regarding the status of the vehicle the previous day. The log updates various information every 5 minutes. Among the data ...
-1
votes
1answer
26 views

what is f option means when using with fgrep [duplicate]

I came across this line of coding of previous developer's script and do not understand. Could anyone please tell me what it means? fgrep -f ${OLD_LOG} ${NEW_LOG} > ${SAME_FILE} 2>&1
3
votes
4answers
475 views

How to use grep on all files non-recursively in a directory?

I want to search for a string of text in all files in a directory (and not its subdirectories; I know the -r option does that, but that is not what I want). Running grep "string" /path/to/dir is ...
-1
votes
1answer
50 views

Reg ex - awk - grep from getline result [closed]

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 ...
1
vote
3answers
88 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
35 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
50 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
34 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
5k 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
1k 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
46 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
295 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
71 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
49 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
53 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
48 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
408 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
44 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 fred....
8
votes
5answers
688 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
47 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
42 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
60 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
2k 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
475 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 "{G|J|...
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 '/denm\....
0
votes
0answers
251 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
357 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
1k 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
827 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
8k 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 /usr/lib/thunderbird/...
0
votes
1answer
930 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 [bold]*...
1
vote
1answer
68 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
703 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
237 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
65 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 ...