grep

Vim: grep's wildcard doesn't work in windows

I try to use vim's internal grep with '**' wildcard as in the following command: grep "test" **\*.txt vim gives the following error: FINDSTR: Cannot open **\*.txt When I remove the '**' wildcard, the command works properly: grep "test" *.txt I changed the backslashes to forward slashes, but it didn't help neither: grep "test" *...

Exploitable PHP functions

I'm trying to build a list of functions that can be used for arbitrary code execution. The purpose isn't to list functions that should be blacklisted or otherwise disallowed. Rather, I'd like to have a grep-able list of red-flag keywords handy when searching a compromised server for back-doors. The idea is that if you want to build a mu...

Trying to make a filter with grep

I'm trying to make a filter that capture all the .exe file lines. For example, from this: [05/Apr/2010:11:00:01 -0300] /~mauro/Lista_conceitos_BD_2004.DOC 200 46080 [05/Apr/2010:11:00:54 -0300] /~lucia/articles/PROPOR96-Rino.pdf 200 153253 [05/Apr/2010:11:01:32 -0300] /~daniel_leite/RenomearTudo/setup.exe 200 1692017 [05/Apr/2010:11:...

How can I search for a string in a log and only fail if I find it in Hudson?

My build and deploy step creates some logs. I would like to search the logs for and fail the build if I see certain strings. A good log looks like log stuff step 1: SUCCESS step 2: SUCCESS A log with failures would look like log stuff step 1: SUCCESS step 2: FAIL My check is grep FAIL /path/to/build.log if [ $? -eq 0 ]; then e...

How to take out some of the new lines of a document

Hey there!! Firstly, I'm really new on this and I'm having difficulties... I have this data: [05/Apr/2010:09:59:34 -0300] /~bcc/topo-zero.html 200 238 2 [05/Apr/2010:10:01:19 -0300] /~bsi/materiais/ed/u6.html 200 286960 3 [05/Apr/2010:10:04:56 -0300] /~firedo/AISG/AISGroupContributions.html 200 33193 2 ...

extract regexp result from string and write it to a variable

Hi, I'm trying to write a shell script that searches in a file specified as argument $1 for a regex and writes the found subpattern into a variable I can then use. let's say my script is called 'dosth.sh' and I have a file 'plot.gp' with the line set output 'test.tex' If I now execute 'dosth.sh plot.gp' the script should extract 't...

Problem formatting a find with sed output

Hi I'm trying to clean a site from a js-trojan for a customer, it has added: <script src='http://nt02.co.in/3'&gt;&lt;/script&gt; to all html-pages. Since it's too many files to manually clean I tried to a do find like this: find ./ -type f -exec sed -e "s\<script src='http://nt02.co.in/3'&gt;&lt;/script&gt;\ \g" {} > {} \; Problem ...

Regular Expressions to match files with speecial format

Hi all I have the following names of files: When x is a number (x could be number between 0 to 100) fileX fileXblabla fileX.X fileX.Xblabla For example fileX --> file1 fileXblabla --> file1blabla fileX.X --> file5.3 fileX.Xblabla --> file2.9blabla my question is how to match each one of the following kind of files under directory ...

Regular Expressions for Linux - scan the Apache HTTPD access log for all the response code other than 200

Hi. This is a question about grep and regular expression. If I want to see all the requests whose response is a 200 code, I can do: grep -e '^.* - - .* .* .* .* .* 200' access_log Quite easy peasy. But what if I want to retrieve all the requests whose response is NOT a 200 code? I would like to be able to do that with only one grep...

Python parsing files

I need to know the best approach for the following scenario lets say we have some huge file which logs the output of the compilation and there are couple of error patterns which I want to test against this file, for eg. error patterns could be - : error: - : error [A-Z]*[\d ]* - [A-Z]*[\d]* [E\e|rror: - " Cannot open include file ...

sed help remove malwarm code from multi files

Hello guys ive this malwarm code in so many files html and php on the server i need to remove them using sed -i expression search all files on dir /home/ find infected files and remove the code replace it withe white space any help ? <script language=JavaScript>var usikwseoomg = 'PaBUTyjaZYg3cPaBUTyjaZYg69PaBUTyjaZYg66';var nimbchn...

Grep and regex: inconsistent behaviour

Hi all, I was working on the Linux box A and I run this: grep '^\S*\s-' access_log That displayed some lines, as expected. Then I moved to the machine B and I launched exactly the same command. But this time it didn't work. I had to launch this in order to get done what I needed: grep '^[^ ]* -' access_log Before succeeding, I...

Unix Grep command

I have to search from codebase of lines having following pattern: "get_token , get_token" For example the below line 'type' should be listed: fn1(string.get_token(), string1.get_token()); Thanks in advance ...

help with unix tar and grep loop

Hi I would like some help in creating a loop that will take one of my files extension .tar.gz unzip it untar it and search the files inside (with extension .tlg) using grep -a >> output.text. In the outout.text i will require the matching data as well as the name of the file and parent tar it came from one this search has been perfo...

How to use unix scripts to show all 'n' characters long group of strings?

This IS kind of linked to another question - http://stackoverflow.com/questions/3171552/code-golf-color-highlighting-of-repeated-text I'm tying to figure out a way of breaking a file into all 'n' characters long groups. Eg: If a file comprises of ONLY the following text: ABCDEFGHIJ And we want it broken into sets of 3, the output sh...

How do I search for anything between these tags

How do I search for anything between these tags, I would like to list all occurences where there is some value between the f:facet xml element <f:facet name="header">Name</f:facet> ...

Get line number while using grep.

Hello I am using grep recursive to search files for a string, and all the matched files and the lines containing that string are print on the terminal. But is it possible to get the line numbers of those lines too?? ex: presently what I get is /var/www/file.php: $options = "this.target", but what I am trying to get is /var/www/file.php:...

grep: operation not supported on socket

I get this error on cygwin 1.7.5-1 under zsh and rxvt when I try to run grep "getDirectories" * It seems to happen once per directory. I successfully ran this operation many times under cygwin 1.7.1 just a few days ago before I had to get a new laptop. Anyone know what is causing this error? ...

Shell script to find, search and replace array of strings in a file

This is linked to another question/code-golf i asked on http://stackoverflow.com/questions/3171552/code-golf-color-highlighting-of-repeated-text I've got a file 'sample1.txt' with the following content: LoremIpsumissimplydummytextoftheprintingandtypesettingindustry.LoremIpsumhasbeentheindustry'sstandarddummytexteversincethe1500s,whenan...

Linux command to find text in most recent file matching name pattern

I have a directory of files like so: parent /dir1 file1 file2 other something name_pattern.o23409284 name_pattern.o29203429 name_pattern.o39208235 /dir2 ... I want to run a command that will look in the newest name_pattern.o* file for a line beginning with: ***END ...