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

learn more… | top users | synonyms

1
vote
3answers
194 views

How to use AND and NOT both in single grep command

I'm creating one of shell script, In which, I need to filter process except own grep process. If I use : echo "step1" psout=`ps -aux | grep 'deluged'| grep '58846'` echo "step2" echo $psout ......
5
votes
5answers
291 views

How to get text from range of dates using grep/sed in large text file?

I have big file text (almost 3GB) - it is a log file. I want to get lines of text which correspond to a range of dates from this file, from 13 July to 19 July. My log format is: 2016-07-12 < ?xml ...
1
vote
1answer
37 views

How can I remove the first whitespace of every line of a file?

I have a file that looks like SPT-CL J0000-5748 J000106.23-574536.8 0.275980 -57.760231 0.7554 0.0003 template 1 SPT-CL J0000-5748 J000049.27-574637.3 0.205320 -57.777050 0.7018 0.0002 template 1 ...
-1
votes
1answer
19 views

Processing large amount of files with lynx/grep. Help needed!

Can someone please help me with this. it worked perfectly for a second now it creates empty files or no files at all, or only prints the first link and not the remaining ones. don't know what is going ...
1
vote
2answers
60 views

Grep in bash script won't work properly

I know there are many similar questions arround the Internet, but I couldn't find a solution for my specific problem. I made this script for an assignment, where I want to find which combinations ...
2
votes
2answers
24 views

tail -f grep for one paragraph (X lines) filter by selected PID

I have a flowing log file that separated by enter each lines its makes problem to just tail it with grep 'PID' it just show 1 line: This is the Sample: [7/12/16 17:00:12:206 WIB] 0000013d ht....
3
votes
0answers
47 views

terminal command | grep IP [migrated]

ifconfig -a | grep 10.16 inet 10.16.x.xx netmask 0xffffff00 broadcast 10.16.x.xxx inet 10.16.x.xx netmask 0xffffff80 broadcast 10.16.x.xxx I have replaced the numbers with x My aim is to ...
1
vote
2answers
37 views

How to Export several grep outputs into one file?

I have a little grep command line that finds certain values in a text file and exports them into a .csv-file. Here it is: cat file.txt | grep 'Values a' | cut -d' ' -f9 >a.csv cat file.txt | grep ...
0
votes
0answers
86 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
65 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
618 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
37 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
27 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
38 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
30 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
564 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
53 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
91 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
36 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
56 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
54 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
7k 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
2k 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
48 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
310 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
94 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
65 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
45 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
706 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
56 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
45 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
67 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
564 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
292 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
412 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
832 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
10k 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
1k 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 $...