grep

Is there any way to use UNIX GREP commands on WIndows operating system

All, I need some command like GREP in UNIX for WINDOWS Operating system, If there any way to use grep or any equivalent command in Windows? Please help ...

getting a substring from a regular expression

Here is the line of text: SRC='999' where 999 can be any three digits. I need a grep command that will return me the 999. How do I do this? ...

Can you mass edit all files returned in a grep?

I want to mass-edit a ton of files that are returned in a grep. (I know, I should get better at sed). So if I do: grep -rnI 'xg_icon-*' How do I pipe all of those files into vi? ...

Find stored procedures not referenced in source code.

I am trying to clean up a legacy database by dropping all procedures that are not used by the application. Using grep, I have been able to determine that a single procedure does not occur in the source code. Is there a way to do this for all of the procedures at once? UPDATE: While using -E "proc1|proc2" produces an output of all lines ...

Why does this `grep -o` fail, and how should I work around it?

Given the input echo abc123def | grep -o '[0-9]*' On one computer (with GNU grep 2.5.4), this returns 123, and on another (with GNU grep 2.5.1) it returns the empty string. Is there some explanation for why grep 2.5.1 fails here, or is it just a bug? I'm using grep -o in this way in a bash script that I'd like to be able to run on di...

Using grep to find files that doesn't contain a given string pattern

I'm using the following command in my web application to find all files in the current directory that contain the string foo (leaving out svn directories). find . -not -ipath '.*svn*' -exec grep -H -E -o "foo" {} \; > grep_results.txt How do I find out the files that doesn't contain the word foo? ...

git grep --cached

Am I misunderstanding how git grep --cached foo works? Running git version 1.6.4.4 or 1.6.5.2, git grep --cached foo returns exactly the same thing as git grep foo. I thought it would work like git diff --cached, searching only changes in the staging area. That's certainly what the man page leads me to believe: --cached Instead o...

Using jQuery inArray with array of JavaScript Objects

Hello all, I'm working with an array of JavaScript Objects as such: var IssuesArray = [{"ID" : "1", "Name" : "Issue1"}, {"ID" : "2", "Name" : "Issue2"}, {"ID" : "3", "Name" : "Issue3"}]; My end effort is trying to remove an object from the array when I know the ID of the object. I'm trying to u...

Grep doesn't work correctly with .as files

Here's the statement I'm running: grep -i -H 'ConfigureControls' *.as Note that I'm forcing file names with the -H flag. What I get back is: } } trac} } this.chairControls.debug.appendText("\nAn error occured when communicating with server:\n" + err.message);l);his.chairXML.storeResult; {ackage {ublic cpublic frequest = ...

GREP - finding all occurences of a string

Hi all, I am tasked with white labeling an application so that it contains no references to our company, website, etc. The problem I am running into is that I have many different patterns to look for and would like to guarantee that all patterns are removed. Since the application was not developed in-house (entirely) we cannot simply ...

Bash alias query

How can I turn the following command into a bash alias? find . -name '*.php' | xargs grep --color -n 'search term' Where I can specify the file extension and 'search term' is obviously the search term :) So what I want to do is: searchFiles 'php' 'search term' How do I pass the input into the alias? Should I just create a bash sc...

GREP: How to search for a value but at the same time exclude some matches

I need a way to simplify this command: grep 'SEARCHTERM' server.log | grep -v 'PHHIABFFH' | grep -v 'Stats' It should find all the lines including SEARCHTERM but exclude if one of the SEARCHTERM lines includes PHHIABFFH or Stats. ...

preg_grep on a larger string

Hi! I need to use preg_reg on some string with content from a html file. $file = file_get_contents($path); $html_array = explode(' ', $file); The problem is that the array looks sometimes like this: [77]=> string(35) "<div> </div> <br> {{testto}} <br>" I have tried to put in some whitespaces there.. :P Won't work.. :/ L...

how to grep a variable in the shell program?

#!/bin/bash for ((var=0; var<20; var++)) do echo " Number is: $(grep 'Multiple_Frame = echo **$var**' 20mrf.txt | wc -l)" >>statisic.txt done This shell program cannot produce correct result which maybe the reason of wrong variable returning in the second grep command. How can I grep a variable within the second echo sentence? to...

Grep a tab in UNIX

How to grep tab (\t) in the file on Unix platform ...

Find lines containing all keywords in bash script

Essentially, I would like something that behaves similarly to: cat file | grep -i keyword1 | grep -i keyword2 | grep -i keyword3 How can I do this with a bash script that takes a variable-length list of keyword arguments? The script should do a case-insensitive match of lines containing all keywords. ...

How can I find all of the distinct file extensions in a folder hierarchy?

On a Linux machine I would like to traverse a folder hierarchy and get a list of all of the distinct file extensions within it. What would be the best way to achieve this from a shell? ...

Really strange grep 2.5.1 bug in cat'd reading long lines

Recently a peer and I discovered an interesting bug in GNU grep 2.5.1 in which standard input with lines greater than 200,000,000 characters causes grep to fail, even if the pattern is not in one of the long lines. If however grep reads the file with grep match file it works fine. It appears this bug is fixed in 2.5.3. cat big_file | g...

Unix awk command regex problem

I have data like this: # data_display ab as we hj kl 12 34 45 83 21 45 56 98 45 09 I need just the first column alone, and only the rows starting with numbers. I now use: # data_display | awk '{ print $1 }' | grep "^[0-9]" Is there any way to optimise it more, like using the regex in awk itself? I am very new to awk. Tha...

Grep search strings with line breaks

How to use grep to output occurrences of the string 'export to excel' in the input files given below? Specifically, how to handle the line breaks that happen in between the search strings? Is there a switch in grep that can do this or some other command probably? Input files: File a.txt: blah blah ... export to excel ... blah b...