egrep

Egrep acts strange with -f option

Hi all, I've got a strangely acting egrep -f. Example: $ egrep -f ~/tmp/tmpgrep2 orig_20_L_A_20090228.txt | wc -l 3 $ for lines in `cat ~/tmp/tmpgrep2` ; do egrep $lines orig_20_L_A_20090228.txt ; done | wc -l 12 Could someone give me a hint what could be the problem? No, the files did not changed between executions. The expected ...

Find Non-UTF8 Filenames on Linux File System

Hi, O/S = Fedora Code 9. I have a number of files hiding in my LANG=en_US:UTF-8 filesystem that have been uploaded with unrecognisable characters in their filename. I need to search the filesystem and return all filenames that have at least one character that is not in the standard range (a-zA-Z0-9 and .-_ etc.) I have been trying t...

Regular expression question

Hi, I am trying to use the cscope-indexer script. But I want to know how to change the following to include *.mm and *.java files? egrep -i '\.([chly](xx|pp)*|cc|hh)$' | \ sed -e '/\/CVS\//d' -e '/\/RCS\//d' -e 's/^\.\///' | \ sort > $LIST_FILE I tried egrep -i '\.([chly](xx|pp)*|cc|hh|mm|java)$' it does not work. ...

Is there any way to embed egrep and wget in my application ?

hello all i need in my application the feathers that the good old egrep and wget give me , but i can't execute them as separate process i need them as embedded functions in my application is there any way to do that ? cross platform and c++ ...

how to find files containing a string using egrep

I would like to find the files containing specific string under linux. I tried something like but could not succeed: find . -name *.txt | egrep mystring ...

grep - search for "<?\n" at start of a file

I have a hunch that I should probably be using ack or egrep instead, but what should I use to basically look for <? at the start of a file? I'm trying to find all files that contain the php short open tag since I migrated a bunch of legacy scripts to a relatively new server with the latest php 5. I know the regex would probably be '/...

Regular Expressions Match Specific Location In File

The file i am working with (oraInst.loc) looks like this: inventory_loc=/u01/app/ORAENV/oracle/oraInventory inst_group=dba I need to use a regular expression to grab the value between app/ and /oracle. In this case it will be ORAENV but it could be any alphanumeric string of any case and length but with no spaces. From what I have re...

Is it possible to do a grep with keywords stored in the array?

Hello, Is it possible to do a grep with keywords stored in the array. Here is the possible code snippet... Please correct it args=("key1" "key2" "key3") cat file_name |while read line echo $line | grep -q -w ${args[c]} done At the moment, I can search for only one keyword. I would like to search for all the keywords which is stored...

Parts of a match in regular expression with egrep

Hello! I was wondering if, with egrep ((GNU grep) 2.5.1), I can select a part of the matched text, something like: grep '^([a-zA-Z.-]+)[0-9]+' ./file.txt So I get only the part which matched, between the brackets, something like house.com Instead of the whole line like I usually get: house.com112 Assuming I have a line with h...

why egrep's stdout did not go through pipe?

Hi, i got a weird problem regarding egrep and pipe I tried to filter a stream containing some lines who start with a topic name, such as "TICK:this is a tick message\n" When I try to use egrep to filter it : ./stream_generator | egrep 'TICK' | ./topic_processor It seems that the topic_processor never receives any messages However, wh...

Help with PHP data mangling as with sed/awk/grep

Ok guys.. I have a HTML i need to parse into a php script and mangle the data around abit. For best explanation I will show how I would do this in a bash script using awk, grep, egrep, and sed through a god awful set of pipes. Commented for clarity. curl -s http://myhost.net/mysite/ | \ # retr the document awk '/\/\a...

grep: excluding lines that begin with a blank character

I have a text file where some lines have a character at the beginning and some lines don't. I want to print the text file to screen, excluding the lines that don't have a character at the beginning. Can I do this with grep? ...

Tarballing without git metadata

My source tree contains several directories which are using git source control and I need to tarball the whole tree excluding any references to the git metadata or custom log files. I thought I'd have a go using a combo of find/egrep/xargs/tar but somehow the tar file contains the .git directories and the *.log files. This is what I ha...

Why doesn't this pattern work in egrep?

Why can't I match the string "1234567-1234567890" with the given regular expression \d{7}-\d{10} with egrep from the shell like this: egrep \d{7}-\d{10} file ? ...

grep from bottom to top of a file

hi, what is the option with grep or egrep through which we can search from bottom to up of a file normally they works in the top to bottom ...

Alternating chars and nested parenthesesin (e)grep

I'm looking for a regex that finds all words in a list that do not have characters next to each other that are the same. (this is an exercise) So abcdef is printed, but aabcdef is not. I tried both egrep "^((.)[^\1])*$" and egrep "^((.)[^\2])*$" words but, other than being not sure which one would be right, they don't work. I k...

grep: "^." doesn't match correctly

Can someone explain why this code doesn't work as expected? I would expect it only to match the first character, and it does with literal characters, but the wildcard (.) and characters classes behave strangely: I use -o just to demonstrate exactly how things are matching, it doesn't change what matches at all. $ echo foo | grep -o '^....

How to return only part of a line with egrep

I have a program that returns something like this: status: playing artURL: http://beta.grooveshark.com/static/amazonart/m3510922.jpg estimateDuration: 29400 calculatedDuration: 293000 albumName: This Is It position: 7291.065759637188 artistName: Michael Jackson trackNum: 13 vote: 0 albumID: 3510922 songName: Billie Jean artistID: 39 son...

Transpose a File in unix

I have file something like this 1111,K1 2222,L2 3333,LT50 4444,K2 1111,LT50 5555,IA 6666,NA 1111,NA 2222,LT10 Output that is need 1111,K1,LT50,NA 2222,L2,LT10 3333,LT50 4444,K2 5555,IA 6666,NA 1 st Column number may repeat anytime but output that i need is sort and uniq ...

egrep regex not working on regex that works in other program.

I have this working regex (tested on regex coach): \n[\s]*[0-9]*[\s]*[0-9]*(\.)?[0-9]*(e\+)?[0-9]* that is supposed to pick up the first 2 columns of this file http://wwwhomes.uni-bielefeld.de/achim/highly.txt I read through the man pages, and it says that ^ will match at the beggining of the line so I replaced \n with ^ but egrep i...