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

learn more… | top users | synonyms

0
votes
1answer
26 views

Trying to organize files by extension using a script (grep, for, foreach, find), but I'm overwhelmed. Looking for advice

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
32 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
189 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
31 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 ...
5
votes
3answers
420 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 ...
5
votes
3answers
297 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
77 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
172 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
60 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
43 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
91 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
106 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
19 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
27 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
67 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
36 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
28 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
19 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
99 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
374 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
141 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
16 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
332 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
141 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
737 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
5answers
229 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
113 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
50 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
56 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
127 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
63 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
63 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 ...
3
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
45 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
62 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
127 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
39 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
263 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 ...
1
vote
1answer
69 views

Parse git log by modified files

I have been told to make git messages for each modified file all one line so I can use grep to find all changes to that file. For instance: $git commit -a modified: path/to/file.cpp/.h - 1) ...
2
votes
1answer
115 views

How to grep the output of youtube-dl?

The normal output for youtube-dl is the following [download] Downloading video #3 of 33 [youtube] WbWb0u8bJrU: Downloading webpage [youtube] WbWb0u8bJrU: Downloading video info webpage [youtube] ...
0
votes
3answers
214 views

Get intersection between two files using command line

What is the most efficient way to get the intersection between two files , there is : sort file1 file2 | uniq -d
4
votes
1answer
311 views

How can i watch the output that was filtered with grep?

I want to watch the changes of the output gsettings list-recursively|grep text-scal which is org.gnome.desktop.interface text-scaling-factor 1.0 com.canonical.Unity.Interface ...
1
vote
1answer
132 views

Keeping color from vim with grep

I like the way vim highlights the output from syslog. However, I only want the most recent outputs to be opened. I tried grep --color=always "$@" /var/log/syslog > /tmp/fileOUT vim /tmp/fileOUT ...
0
votes
2answers
299 views

Find specific word in all files in and beneath current directory

I want to find all files, and print the path and filename, for any file where the text "Numlock" is used - whether it is lower-, upper- or mixed-case. What command should I use ?
1
vote
1answer
118 views

How can I extract pages containing a given string from a PDF file?

I have a PDF file containing 100 pages. I would like to extract those pages containing a particular string. How can I achieve this? Maybe by using ghostscript on the command line? For what it's ...
4
votes
2answers
703 views

Filter terminal command to text file

Problem: I have dmesg | grep ttyUSB command that has the following output: [ 7.648896] usb 1-2: GSM modem (1-port) converter now attached to ttyUSB0 [ 7.649091] usb 1-2: GSM modem (1-port) ...