1
vote
1answer
32 views

Grep and What If 75

I'm trying to run the command from What if 75: cat wordlist.txt | perl -pe 's/^(.*)$/\L$& \U$&/g' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' '2223334445556667777888999' | grep -P "(.)\1\1\1\1\1" I ...
3
votes
1answer
53 views

Using grep to filter output of a process

I'm using command | grep -v "JavaScript strict warning" to filter the output of a command (hiding warnings). The grep command works fine when I test it like this: $ printf "JavaScript strict warning: ...
1
vote
1answer
65 views

How to redirect ALL output from a command in Linux

I'm running Gentoo Linux. A program (equery) outputs a massive list of all the currently installed packages (equery list "*"). I want to find out which of them are unstable. Equery marks the unstable ...
1
vote
2answers
49 views

Tail and grep recursively?

Trying to tail though a list of domains to search for a hacker code. All the files that I'm looking for are the same so I was trying something like this: grep -rnl * -e "Ai9LbaFz7lC13SwzDxAYT72vwA" ...
0
votes
1answer
681 views

Recursive zgrep not working

I have a directory hierarchy that contains numerous .gz files. I want to be able to recursively grep them for the string "foo". From what I've read online the following should work: zgrep -R -H ...
1
vote
2answers
57 views

How to save linux command?

I am using grep -r [^a-zA-Z0-9]myVariableName[^a-zA-Z0-9] -n JS_files/ as mygrep file grep -r [^a-zA-Z0-9]$1[^a-zA-Z0-9] -n JS_files/ and then sh mygrep myVariableName But then I lose the ...
2
votes
3answers
116 views

What does really mean null string?

I'm sure most of us know that when we want that some regex matches with a string at the begin of the line we must use "^" ... But, I'm trying to understand what really means "empty string at the ...
0
votes
4answers
77 views

Count lines with alphabet in linux

I have a file with a number of lines in a file filename. I want to count how many lines start with character 'a', with 'b' and so on in one go. What command i should execute.?
0
votes
2answers
158 views

Writing a single line command that interprets conditional output from pdbedit

I would like to run a command on a single line that will tell me if the flag is set for a user's password to be changed on next login. This command will interpret the output and return a true/false. ...
0
votes
1answer
109 views

Find a pattern in a line, and append that matched pattern to the same line

I'm trying to pull a job number out of notes listed in a csv, and then append that number to the end of the line, preferably through sed, awk, grep or perl (which I have installed in Cygwin. Here's a ...
0
votes
2answers
102 views

Linux output line numbers where string match appears

what I'm looking to do is boost the command I already have to return line numbers of where the specified string appears: grep -r -l -n -w "ePKI" /home/websites/www/* > /home/keywords.txt The ...
0
votes
1answer
70 views

How can I open a set of files in sublime based on their contents

I am trying to find all the files that contain a search term: grep -lir "Search" . and pipe that into sublime: grep -lir "Search" . | subl but all this does is open a single file in sublime ...
0
votes
1answer
56 views

Search files for text matching format of a Unix directory

I am attempting to search through all the files in a directory for text matching the pattern of any arbitrary directory. The output of this I hope to use to make a list of all directories referenced ...
3
votes
2answers
824 views

Efficient way to search string within file find and grep

I am searching all files containing a specific string on a filer (on an old HP-UX workstation). I do not know where the files are located in the file system (there are many directories, with hudge ...
2
votes
3answers
258 views

How to use grep to search for regular expressions themselves, without parsing them

grep . filename.txt This just returns all of the contents in filename.txt, because . is a regular expression that stands for any character. How do I use grep to search for periods, or other regular ...
1
vote
2answers
243 views

netcat output into separate files using string delimiters

I want netcat to pipe the output of a tcp/ip connection to commands that examine the output and split it into distinct files separated by the strings "msg" and "/msg" from the output, something like ...
3
votes
1answer
2k views

Using grep to remove lines from a file which contain a string from another file

I have a file containing words (one per line) such as Dog Fish Cat Shoes I have a secondary file in CSV format such as 1,shoes,red 2,apple,black 3,fog,blue I would like to use grep with ...
0
votes
4answers
204 views

Extracting specific line of text with grep for use in conky

I'm trying to extract the directory of the current playing song in Quodlibet for use in attempting to display album artwork in conky. In QL's current file ~/.quodlibet/current there is a line that ...
2
votes
2answers
264 views

Grep default color option

grep is one of the most commonly used command in linux. It feels to me that its basic feature to highlight the string you searched for on the output lines. this can be achieved by --color option. ...
1
vote
2answers
228 views

Is there a better way to do this command to find strings in a file excluding special characters?

Is there a better way to do this command to find strings in a file excluding special characters? Currently I'm doing: strings file.abc | grep -v \= | grep -v \] | grep -v \) | more I'd like to add ...
6
votes
2answers
491 views

Why is the grep/-r/--include combination slower than the find/-exec/grep combination?

From my understanding, the two following commands roughly accomplish the same thing: Command 1: find -name "filename.xml" -exec grep someString {} \; Command 2: grep -r --include=filename.xml ...
2
votes
2answers
914 views

Command-line CSS selector tool

Question What tool (preferably for Linux) can select the content of an HTML element based on its CSS path? Example For example, consider the following HTML document: <html> <body> ...
14
votes
1answer
11k views

What is the difference between grep, pgrep, egrep, fgrep?

I'd like a walk through on the differences between grep, pgrep, egrep, and fgrep and how I would use them.
3
votes
4answers
994 views

Using grep to display second character in string?

I have a string that is always 3 characters... the first one and the last one are always the same. example: ▁▅█ Is there a simple way to only display the one in the middle? (which is the only one ...
5
votes
1answer
670 views

What does the grep switch --color=auto do?

What effect does auto as an option for the --color switch have in grep? When does grep decide to color the the matching strings, and when doesn't it?
0
votes
1answer
200 views

How to pipleline stderr in cmd.exe?

Some programs would prefer to output the help message in stderr. I want to search the help message with grep command, xx /? | grep regex? How could i do this?
4
votes
1answer
116 views

Running a command on all files that contain a string

I'm finding a bunch of files with find . -exec grep -l mypattern {} \; What's the simplest, most elegant way to run a certain command separately on each of the resulting list of files?
4
votes
2answers
2k views

Grep in Mac OS X's terminal — only displaying one color

I am used to grep being able to color the filename, the line number, and the match itself. These three ought to be different colors. This works flawlessly on a Linux terminal and even MinGW on ...
1
vote
3answers
3k views

Search for files and print their full path

ls -R /media/X | grep filename lets me search for file names, but it only prints the file name and not the directory it resides in. How can I print the file name and its directory?
1
vote
2answers
280 views

List all files in a directory matching a string and copy output

I'm trying to create a series of playlists on my MP3 player, running Rockbox, by finding a file matching a string, using find /cygdrive/g/MUSIC -type f -name "Search Criteria" | ...
1
vote
2answers
1k views

Get the most common appearing lines from file in Linux

I have a text file that has various words per line. How can I find the 12 most frequent appearing lines in the file and display them? I am not very good with scripting commands. If I could get the ...
0
votes
3answers
194 views

Count all files without using find

How can I count all files without using find and only grep? I tried using ls recursively but how can I pipe that to grep and count files?
0
votes
1answer
385 views

How to find the last match of a string in a bunch of files

I have a bunch of files, I'd like to find the last match of a string in each of them. grep text *.file gives me all the matches not the last ones. ls *.file | xargs grep text | tail -n 1 gives me ...
0
votes
2answers
1k views

How to use Grep in Unix command line?

I want grep all lines containing words that start with "H" and end with "d". How would i do that? I found that grep ^H will give me the H for everyline.
11
votes
2answers
6k views

Counting total number of matches with grep instead of just how many lines match

Does grep offer a way to count the total number of matches it makes? The -c option only returns the number of lines that matched the regex, but in this case I have multiple matches per line.
1
vote
3answers
194 views

How can I determine whether different commands using grep, find and xargs do the same thing?

Do these three commands do the same thing? A command that uses grep. grep "a" -r . A command that uses find. find . -exec grep "a" {} \; A command that uses a grep on a find through xargs. ...
1
vote
6answers
1k views

Finding files based on date, without using `find`

I know find can do what I am looking for, but I am wondering if there is an alternative way to find files on the filesystem either created before/after a certain point, or at a certain time. ...
7
votes
6answers
3k views

Using an index to make grep faster?

I find myself grepping the same codebase over and over. While it works great, each command takes about 10 seconds, so I am thinking about ways to make it faster. So can grep use some sort of index? I ...
30
votes
7answers
68k views

Command prompt (MSDOS Windows 7) grep equivalent?

Is there a command prompt (Windows 7) grep equivalent? That is, I want to filter out the results of a command: Bash use: ls | grep root What would it be from a MS-DOS command prompt?
3
votes
2answers
7k views

How to find file with name=“php.ini” on linux using grep command

How to find file with name="php.ini" on linux using grep command ? Can anybody show me ?
1
vote
1answer
628 views

How can the Windows Command Line do a grep -o?

Is there a way in Windows to get a matching string within a string? echo hereisastring | find "is" and just display is without using grep The following worked using FIND. credit to Hello71 ...
3
votes
5answers
2k views

grep -r not working on Solaris

How can I do recursive grep on Solaris? When I tried, I received this error: -r: invalid option.
5
votes
3answers
1k views

Showing the line count of a specific file

Is this the correct way to show the line count of a specific file? cat file | grep * -c
1
vote
2answers
86 views

Trying to cleanse log files on a Linux machine, currently using sed

I have a large amount of log files that I need to remove sensitive data from. The sensitive data is provided to me in a text file and is prone to change. I had hoped to do the equivalent of this: ...
3
votes
2answers
196 views

Simple (?) Unix Grep Command

How do I recursively view a list of files that has one string and specifically doesn't have another string? Also, I mean looking inside the files, rather than the file names.
1
vote
1answer
236 views

How do I grep help output in linux?

When I use a switch that doesn't exist in commands such as lsof and ps there is a lengthy help menu that is returned. Instead of reading the whole thing I'd like to be able to grep it for the switch ...
0
votes
4answers
462 views

Show the matching count of all files that contain a word

What is the single command used to identify only the matching count of all lines within files under the /etc directory that contain the word "HOST"? I should list only the files with matches and ...
9
votes
7answers
5k views

Advantages of cat'ing file and piping to grep

Are there any additional advantages of cat'ing a file and piping it to grep, besides convenience? The convenience being that, when I retrieve commands such as those below from my history, the cursor ...
0
votes
3answers
465 views

How do I run a command on each file within a directory that matches a pattern?

I'm trying to run a command on every file within a directory (recursively) that matches a pattern. I need the filename of each item that matches for the command however. This is how far I've got: ...
3
votes
4answers
742 views

grep not functioning correctly

I've been happily using grep for many years without any issues, but since today it quit working. During the past hour I tried this and that, but enough is enough, I'm posting the bastard here: On the ...