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

learn more… | top users | synonyms

1
vote
3answers
21 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
16 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
27 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 ...
1
vote
0answers
37 views

Why can't I redirect grep output to file?

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
26 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
22 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
218 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
0answers
24 views

Issues with Grep

Why does the bottom line output "0" into the "AD-Results-$month-$Y" file? First grep command fgrep "$month $D $i:" $Filetmp > TempOutput Grep command to read "allows" from tail of ...
0
votes
3answers
30 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
34 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
96 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
34 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
63 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
34 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
34 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
46 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
46 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
190 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
67 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
104 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
70 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
273 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) ...
1
vote
1answer
214 views

Difference between 'grep' in Ubuntu and Kali Linux?

I always used the following command to filter out my contacts email addresses from a directory in Kali Linux: grep -rIhEo "\b[a-zA-Z0-9._-]+@[a-zA-Z0-9._-]+\.[a-zA-Z0-9._-]+\b" >> 1A I tried ...
4
votes
2answers
594 views

regex search works with `grep -E` but not with bash script?

I use the same regex with grep and it gives me a match but when doing it in a bash script, it return no match. Test String(part of the file testregex.txt): <a ...
1
vote
1answer
70 views

Searching for file contents on whole disk

I am trying to find my old IP address in config files in order to replace it by my new IP address. I found one answer that proposes the command sudo grep -HrnF '1.2.3.4' / to find those IP ...
2
votes
3answers
106 views

Search and print the lines from the output which can contain lines with errors

I have a command example, device list which gives me all devices with their status as okay or error in the following format [okay ]: you are listening on : 11 [error ]: not currently ...
1
vote
2answers
67 views

how to trim dpkg upgraded packages list

Latest upgrade borked my system and I`m trying to revert the last upgrade. I opened my comp with live USB and chrooted to partition that is OS installed. I get the upgraded packages with cat ...
0
votes
1answer
50 views

grep keeps printing the same string

I typed grep ch->spl[4] * into my shell to look for something in a mud code and its broken grep now. Any time I try to grep anything pretty much it puts the spl[4] before the filename like this. ...
2
votes
3answers
1k views

Using grep to search texts with single quote?

I am using gedit text editor with embedded terminal in ubuntu 12.04. I'm trying to search for some text using grep. I want to search for this line of code 'type' => 'select' I tried: grep -r ...
1
vote
2answers
58 views

Find word that has more than 50 characters

I am trying to use find in combination with grep to find all the php files in my web server which have a word (any sequence of characters except whitespace) with more than 50 characters. I have this ...
0
votes
1answer
27 views

Use locate to find name in directories only

If i lost a file I use locate a lot. Works perfectly and with grep you can quickly find back what you looked for. However, often it generates a lot of output which is not always easy to filter. One ...
2
votes
1answer
252 views

omit filenames in grep

I am greping a string from multiple files, but the one undesired side effect, is the filename prefacing the output. How can I suppress the filename outputs using only grep? $ grep -i lp lpNet* ...
2
votes
2answers
47 views

Efficiently search sorted file

I have a large file containing one string on each line. I would like to be able to quickly determine if a string is in the file. Ideally, this would be done using a binary chop type algorithm. Some ...
1
vote
3answers
50 views

I have difficulties with regex to pull certain information from a data file

The data I am working with data that has this format: 1880 20 David 7570 Mabel 13096 I need to pull the year (1880), the rank (20), and the name only (David or Mabel). The end result is: ...
0
votes
1answer
145 views

sed, grep, and awk file sorting

I'm trying to get all the files which have 'load' in their names from a directory. I'm trying to do: find -type f | sed -s 'load However, I recurrently receive an error sed: -e expression #1, char ...
0
votes
0answers
68 views

Option for GREP only non-default processes and services?

is there any option for grep only non default processes and services? I know how show all of this and export to file, but manual reading and deleting line by line is not ideal. :-) Thanks for your ...
2
votes
1answer
1k views

Using Modifiers of Perl-compatible Regex (PCRE) in grep

According to grep --help and man grep, we can use the -P option in order to interpret the pattern as a Perl regular expression (PCRE, to be precise), instead of the default POSIX basic regular ...
1
vote
1answer
66 views

Assigning grep output to a variable

In a terminal I type: grep '<td><a href="http://www.blabla.cc' file.txt works fine. But if I type: var= `grep '<td><a href="http://www.blabla.cc' file.txt` I am unable to ...
0
votes
3answers
197 views

Why is my grep + regex not working?

I recently decided that enough was enough -- I was going to learn to use grep fluently. It's been all of three hours and I'm already stumped by this toy problem. I'm currently syncing a RAID5 array, ...
0
votes
0answers
54 views

i use grep file to search disk file but have many file doesn't exist alert

I use this command: sudo grep -R 'mode_t st_mode' but have many alerts that say many files do not exist. grep: /usr/share/pyshared/numpy/core/include/numpy/cfunc.h: do not have that file or ...
3
votes
2answers
479 views

grep string from a pcap file

I'm trying to figure out the correct command syntax. I have a pcap file, and I want to use grep, and grep only to take out all of the uniq ip addresses from without the file So assuming the file is ...
0
votes
1answer
193 views

how can i use grep to find IPV4 Number in a pcap file with regx syntac?

I'm new in ubuntu. I have this IP regex '\b((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\.|$)){4}\b' I have a network pcap file, I want to use this regex and the grep -e to find all IP address in the ...
0
votes
1answer
99 views

grep multiple files into one set of data

lets say i have few files which have structure like file1.txt apple fruit tomato vegetable file2.txt apple red green tomato green yellow is there a way to grep at once these 2 files (or more) ...
2
votes
1answer
96 views

grep on --help doesn't work on some commands

I just wondered why you can't grep on some --help commands. For example if I use ifconfig --help | grep unix it still prints the whole help instead of the line with unix. But on grep --help | grep ...
1
vote
3answers
261 views

Finding certain strings with grep (or similar)

I have two parts of a string that I know, called phrase1 and phrase2 that are in the same line of a file that occur multiple times throughout the file. I need to extract these lines from the file; ...
3
votes
1answer
95 views

Did grep change how it uses regexp?

I used to run commands like: find /dev | grep sd* to output a list of all the drives attached to my computer. It appears that I now have to add any random character before the star in order to get the ...
0
votes
1answer
46 views

how to always use rgrep with color

Replace grep command with grep -n --colour? is there anything similar for rgrep auto color?
1
vote
2answers
109 views

Problem with grep command

I have three files testx,testy and testz all in same directory Sikh. All three files contain same data or content. The contents are: aaabb Aaaaa AAAAA bbbcc Bbbbb BBBBB ff–ff Ccccc CCCCC ...
2
votes
3answers
4k views

What is the meaning of “ps -aef | grep $(pwd)” command?

What is the meaning of this command, what does it do? ps -aef | grep `pwd`
0
votes
1answer
53 views

Extract numerical value from string

I want to extract the numerical value out of the below command output : bash-3.2# psrinfo -pv | head -1 The physical processor has 1 virtual processor (0) That is, the output should be "1". Can ...