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

learn more… | top users | synonyms

0
votes
0answers
31 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
35 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
16 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
25 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
16 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
3answers
44 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
34 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
43 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
34 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
40 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
296 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
33 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
449 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
363 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
21 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
97 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
67 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
247 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
68 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 ...
-5
votes
1answer
45 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
108 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
116 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
21 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
30 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
69 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
37 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
37 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 ...
2
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
20 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 ...
2
votes
1answer
113 views

'grep' command not working on Lubuntu

I'm using Lubuntu 14.04 with a fresh install (Monday) and I noticed that my grep command doesn't work. Whatever I do, it shows me the grep usage page. For instance, if I try to run: grep test * or ...
0
votes
1answer
414 views

Return only line number, if pattern 'Exist' and 'Not Exist'. using 'grep' command

I have this sample file for my input: xyxxyx xyxx xxyx yxyy yxyx xxyxxx xx xyx xxx x y x xxyy yxxy xyxxy xxy y x y xyxy xyx yyxx xyyxyxy xyx yxyy xyy yxyx xxyxyyx And I tried to find only "xyx" ...
2
votes
2answers
143 views

append a word to the end of a line in txt file

I have a file that should have "OK" at the end of a certain line the line that should be modified is the first line not ending with "OK" I can grep the file to get the line to be modified using ...
0
votes
0answers
18 views

How do I djvubind on ls and grep result?

How do I djvubind only files that are in ls | grep -P "page\\d\\d\\d.tif"?
4
votes
3answers
363 views

Searching for patterns in csv files

I have file.csv that looks like this 4,6,18,23,26 5,12,19,29,31 2,5,13,16,30 9,10,24,27,32 4,5,10,19,22 4,6,8,10,25 2,3,4,25,11 I want to find some patterns and save them in another log file ...
0
votes
1answer
183 views

Linux : Data extraction from text file

I have a text file in which thousands of data is there. eg. id=row_value profile=row_value name=row_value email=row_value address=row_value id=row_value2 profile=row_value2 name=row_value2 ...
19
votes
3answers
851 views

Saving output of a grep into a file with colors

I need to save the result of a grep command into a file, but I also want the output file to be formatted and keep the colors just like in the terminal. Is there a way to do that? Maybe make grep save ...
4
votes
6answers
255 views

Bash script programming: how to match pattern in string?

How I can get this whole value 7I45432ZX from below lines: PW*3434*453*256*PE*UB PO*00*NE*7I4543 2ZX**20140617 PW*3434*453*256*PE*UB PO*00*NE*7I4543 2ZX**20140617 This is the code I tried: grep ...
2
votes
3answers
136 views

How to use grep to search for a pattern which starts with a hyphen (-)?

sudo find / -name "*" | xargs grep -sn --color=auto "-j" Above command returns below: grep: invalid option -- 'j' Usage: grep [OPTION]... PATTERN [FILE]... Try `grep --help' for more information. ...
0
votes
1answer
54 views

Check user input is alpha numeric

Hi Im not any sort of programmer but found myself creating an install script which installs mySQL which works fine. I would like to improve the script by asking the user to enter text that will be ...
-1
votes
1answer
60 views

list directory name of symbolic link

I am trying to find all the symbolic links on my system with name keytool. I use the below command : ls -lR | grep keytool It gives some results, but i want the directory names as well. So i use ...
2
votes
0answers
146 views

Why can't I redirect grep output to file? [closed]

I am running command like this. # ( ( partclone.restore -X -s some.img -o /dev/sda3 2>&3 ) 3>&1 ) | grep Completed Completed: 0.40% Completed: 1.23% Completed: 2.07% ... ...
0
votes
1answer
99 views

Search for files contain lines with many conditions

I can search for files which have a specific word by using grep grep -l "word" /path However what if I want to search for files which have "word 1" and "word 2" in a same line? I can use: mkdir ...
0
votes
1answer
80 views

How to filter grep results?

I am new at writing scripts. So I am hoping this is simple. The script I am writing is used to gather system information and save it as an html file. When I run: sudo lshw -short it list all of ...
4
votes
4answers
2k views

Redirect an output to a file from command piping grep

I am running this: cat /dev/urandom|hexdump| grep -i "ffff f" > random and I get nothing in file random, it remains zero length after the command is interrupted. How to make it writing output ...
0
votes
3answers
47 views

Filter only path of files (without directories path) from output using pipe |

rpm -qpl dhad-9.0.27891-2.x86_64.rpm allows to display all file paths and directory paths of this package . Example of output : /opt/dhad/tv_bin/wine/lib/wine/winmm.dll.so ...
0
votes
1answer
70 views

Can someone explain what this grep/cut/awk command is doing

This is inside of a .sh script file: cd /somefolder IP=$(ifconfig | grep 'inet addr:'| grep 168 | grep 192|cut -d: -f2 | awk '{print $1}') The /somefolder has another folder list with a single ...
1
vote
2answers
130 views

Grep, no value return

I am searching for a word, in this case "hehe" that is located in the file findTest by using grep, but when i initiate the search: grep -r "hehe" or grep -lr "hehe" it starts but after 5 min ...
1
vote
3answers
40 views

Document Sorting Section

I have some sample data below (call it test.txt). I would like to split this big document into 3 documents by searching the first two digits in the 4th column. I'm pretty new with Linux (Lubuntu ...
0
votes
0answers
287 views

Cannot run the terminal: “Not such file or directory” and “hostname has changed”

My problem is: I can't use the terminal in Xubuntu 14.04. If I launch it, this error is appearing: grep: /opt/aster113/etc/codeaster/asrun: No such file or directory Hostname has changed, running ...
1
vote
1answer
38 views

Changing current directory to directory that have identifier as the substring

My terminal is currently in the home directory, and the home directory contains a directory which have "round" as the substring. Is there any way to directly change to that directory without typing ...