Software :: Use Regex Or Pcre To Find Out The Matched From Multiple Textfiles?
Feb 7, 2010I am trying to use regex or pcre to find out the matched from multiple textfiles. how to write a relative program on linux C?
View 3 RepliesI am trying to use regex or pcre to find out the matched from multiple textfiles. how to write a relative program on linux C?
View 3 RepliesI have a sed match that matches for certain string of a regex expression:
Code:
tname=$(echo "$contents" | sed -n 'some pattern')
How do I match for multiple strings in the $contents and return them as an array? for example
Code:
contents="this is a text, just to match patterns, here is another text to be matched"
the sed func would be able to recognize both "text"s, but only one is outputted?
Possible to put it in an array? so ${bar[0]} gives one and ${bar[1]} gives another
I'm fairly comfortable with emacs but I can't seem to find how to do this. I deal with a lot of text files and find myself performing a lot of regular expression replacements to correct the formatting of the text -- or to extract certain tidbits of data from large ugly-looking files.
I know how to perform a regular expression replacement in one buffer at a time. But how do you perform a regular expression search and replace across all open buffers? I have found a method to perform a regex search and replace across a directory by marking files but I need to do it in the open buffers.
I have written a regular expression (tested in regexpal and regextester alpha something) with which I want to replace something like code...
but it only matches functions which occupy one line only, despite my tests showing multiple line matching in javascript testers online and using the m and s flags (which should make it multi line no?)
I'm using bash scripting to find any file that matches a path governed by the following regular expression:
"(monthly|nightly).[0-9]+/home/(user1|user2)/.mailbox/"
to match files like:
monthly.9/home/user1/.mailbox/l23131564
nightly.15/home/user2/.mailbox/cur/6546213
I've tried:
Code:
myRegex="(monthly|nightly).[0-9]+/home/(user1|user2)/.mailbox/"
find ./ -regextype posix-egrep -regex $myRegex
and it just spins and never gives me an answer, even though the file structure isn't that big.
I have a ton of files that are timestamped directories. These all look like2011-06-24_13.53.36 // a directory name for june 24th, 1:53:36 pmI have thousands of these directories. I want to do operations on some of the older ones. Let's say I give it a string for date time that matches that exact format, like i'll give it2011-06-25_00.00.00 // june 25th, 12amI want to find all the directories BEFORE my time. So if i give the string for 12am on june 25th, i want to find all the directories before then.If not i can find EVERY directory i have like this and then filter after wards. The created/modified dates are not tied to the actual timestamp im looking for (that would make this easier)
View 2 Replies View Relatedi am trying to find all 3 and 4-character length words in my file (which is huge and has alot of entries in it, a big fat wordlist!).My attempt with this regular expression (which I thought should work, found something on length search here: [URL]
cat sorted_noapostrophe.txt| grep '.{3,4}'
but it returns no results? Also to find any words starting with 'f' which are between 3 and 5 characters (inclusive) long, how can this be done?
am trying to find a proper regex to match the two numbers in the following log entry.
Code:
15:08:16.142 INF Found 64468
15:08:16.142 ERR [Uniform test code=64469]
Basically the pattern I'm looking for will match the two different numbers spanned across two lines.Thought I need to use multi-line mode as follow but this doesn't match on [URL]...
Code:
/^($[0-9]{5}
[0-9]{5})$/m;
I have the following command which finds all files that have changed in the last day and lists them. How can I exclude hidden files like .bash_history?
View 3 Replies View RelatedWhat I am doing is reading the text from a text document and storing all of the text inside of a ArrayList. I then set one of the values of the Arraylist as a string. I want to use regular expressions find out what the first two characters of the String are. if first two characters = "//" then function(); I only care about the first two characters though. If you need any more information, just ask.
View 4 Replies View RelatedI want the LAMP server to present an upload page to the user The user uploads a zip file containing txt files which are tables in clear-text format The server : opens the zip validates the text files (going to skip this for now, but will try to make later) converts the files as here imports them to MYSQL tables All this is supposed to happen automatically, then the user can immediately use the website with the updated data How to implement this (esp. the first part with the zip file)
View 1 Replies View RelatedIn pcre manual, to use a backslash to escape a special character. But in fact, it is need to use double (\) backslashes to do escape for a pcre program on linux C,why?
View 5 Replies View RelatedI'm having trouble updating PCRE library on my web server. Even though pcretest -v show 6.6 it still showing PCRE 8.10 on my working devserver. But our live server shows PCRE 6.6
I'm not sure what I should be updating here. PHP, HTTPD or PCRE ?
I would like to write a newline delimeted rules file using PCREs for use with the grep command. Grep has the option -f to obtain the search pattern from a file, and option -P to search using PCREs. However, these two options do not work together. The -f option only seems to work with fixed string rules.A friend previously helped me get around this limitation somehow, but I can't remember how he did it. I also would like the ability to add comments at the end of each rule in the file.
View 11 Replies View RelatedI'm at the bottom of the bash learning curve, looking up, hoping someone can toss me a line. I need to update tracker on my system but this will erase the metatag database I've been building up over the course of months for the purpose of indexing a news archive. So the solution seems to be, 1) save the output of tracker-tag to a text file for all relevant files within a directory, 2) upgrade tracker (since the version in the Ubuntu repositories is very much out of date) and then 3) use a script to parse the text file and pass appropriate arguments back to tracker-tag to rebuild the database. It sounds as though it ought to be simple enough, but I need a push in the right direction, which hopefully will not be off the cliff. Before I confuse my metaphors any further, here's what the text file looks like.
[Code]....
i'm trying to install php zip extension through pecl, issuing the following command pecl install zip but i'm getting the following error:
[code]...
I am trying to zip up my Home directory (zip -r -9 /Destination /home/joe) & when I do I get the error below in a constant loop until I hit ctrl-c to stop. This use to work fine. The only change I made lately was change the permissions to 700 but I don't see how this would do anything.Quote:
zip warning: name not matched: /home/joe/.wine/drive_c/users/joe/My Documents/.wine/drive_c/users/joe/My Documents/.wine/drive_c/users/joe/My Documents/.wine/drive_c/users/joe/My Documents/.wine/drive_c/users/joe/My Documents/.wine/drive_c/users/joe/My Documents/.wine/drive_c/users/joe/My Documents/.wine/drive_c/users/joe/My
[code]....
What I am trying to do is to convert a mass of files from standard Windows text encoding to UNIX encoding(462 .txt files). After a bit of searching, I found this bit of code, changed the necessary parts, put in "Sleep" so I could see the output and ran it:
Code: #!/bin/bash
FROM=iso-8859-1
TO=UTF-8
[code]...
Using the regex.h functions, how do you:
1) get the matched strings?
2) get the strings that matched sub-expressions?
In Perl. I can't find the global variable for $_ (except not $_ it's the one to specify AFTER the matched string.) its dollar sign then something else. Does anyone have a cheat sheet for global symbols?
View 1 Replies View RelatedI have two text file named 1.txt & 2.txt.
1. txt contains 5 laks of mobile number.
2. txt has 60 laks of mob no.
Situation is that I want to find and delete numbers in 2.txt which already in 1.txt. Any perl or bash script or any other way to get the work done.
I tried the following:
#! /bin/bash
IFS=$'
' for NAME in $(cat one.txt)
do sed -ie "|^$NAME$|d" two.txt done
echo "***DONE***"
It works well with smaller file but it take very very long time even processing 10 thousand numbers.
I remember reading that using sed, you can do this with parentheses: s/abc(something)def/(something)else/g I can't find an explanation of how to do something like this with Awk. Say you have this in an HTML file, where (number) stands for a one or two-digit number:
<sup>(number)</sup>
And you want to change that to this:
<a name="(number)t" href="#(number)b"><sup>(number)</sup></a>
How would this be possible? Would you have to use sed?
need to modify some scripts to repeat the commands in them until a variable returns a proper value. I need it to add some redundancy to some scripts i use to upload files to a remote server.This is an example of a portion of those scripts:
Code:
################## site UPLOAD ##################
site_login=$(curl -c $site_cookie -L -F user=$site_user -F pass=$site_password -F
[code]....
Is there any way to add a character to the end of a line when a certain match text is matched. I have a text file where any line that contacts text XYZ a z is placed at the end.
View 1 Replies View RelatedI'm using sed to remove certain line in a text file based on a match with 2 variables from input. Here is how it looks like in file
Philip S:Odds:45:343
Mike Junior:Odds:3:56
I prompt for 2 inputs in variable form which is compared to the first 2 fields of the above text (: seperated). So say i enter Philip S and Odds then it should delete the entire first line.
I am working at a client who has a project where code is a mixture of different source control systems. So a layout might be like this
project/a/.svn
/a/subfolder/.svn
/b/.hg
/c/subproject/.svn
/d/.hg
So I am trying to put together a simple command that when executed from the project folder will run the appropriate hg/svn command in each project i.e:
[Code]...
Since the client has many such projects, Instead I am looking for a solution similar to find -exec where the svn/hg commands are automatically executed on each first level of match (i.e. svn up is run in the project/a folder but not in project/a/subfolder). How can such a command be constructed ?.
When I install pcre on fedora 11, the configure and make operation goes smoothly, but can't do "make install".
View 7 Replies View RelatedI'm trying to run multiple commands on things I have found, how can I achieve this? find . -exec cmd1; cmd2 does not seem to work; it instead runs cmd2 after cmd1 has been executed on every file.
View 2 Replies View RelatedI would like to find all the files that contains the strings I'm searching.
For example (it's just an example), I would like to search all the files in "/etc" that contains "eth0" and "us", whatever where are located those 2 strings, the important is that the 2 strings are in the files listed.
It would be something like a "grep -lr 'eth0' *" and "grep -lr 'us' *" but in one time/command, so that I don't have to make a comparison of the 2 list of files resulting from the 2 "grep" commands given higher.
I found a script on webmaster world that mostly does what I need it to, but have been making modifications to tailor it to my specific needs.I know that //..*/ tells awk to ignore hidden directories, how do I define more directories to ignore? (i.e. temp, var, etc)? I've tried playing with prune before the awk command with limited success...I know that there are many ways to do the same thing and keep running into brick walls.
View 11 Replies View Related