General :: Expressing A Specific Range With Regex And Perl Extractors?

Feb 27, 2010

I am tryng to get values BBA 204- BBA 324 from a log file.

this is my script:

zmore log.gz | perl -nle 'print for m/BBAs[2|3][0-9][0-4]/g' | sort -u | perl -ne 'print if /^BBAs204$/../^BBAs324$/'

the first perl one liner gives me everything from BBA 200 to BBA 394, and the second perl one liner cuts it down to BBA 204 to BBA 324

Is there a elegant regex that will allow me to skip the second perl one liner and just take out the BBA 204 - BBA 324

View 2 Replies


ADVERTISEMENT

Programming :: Specific Regex Pattern In Perl?

Feb 23, 2011

I'm fairly new to Perl and regular expressions. I have a large collection of files with their file names in the following general format: string - another string with spaces (2004) [year].ext I would like to know how I could create a regex to separate out:

the first string
another string with spaces
year
extension

If you know of a better way of doing it without regular expressions, I would be happy to hear that way too.

View 13 Replies View Related

General :: Specific Range Of Records?

Feb 24, 2010

I am having a log file where there is some discontinuous of dates are there but if i go for range of date to find the records, if is some date is missing the result is displaying full file list( Start date to end of file ) How could i restrict the result upto the mentioned date range.

Code:
$cat sample.log
Jan 03 -error yyyy-1234

[code]...

View 6 Replies View Related

Programming :: Perl Regex Matching HTML?

Mar 19, 2010

I'm trying to find out how to extract the string between the 2 <title> tags: <title>this is what i want</title>.I found lots of results but nothing I've tried works.. EG:$page =~ m/<title>($.)</title>/gism;

View 2 Replies View Related

Programming :: Insert A Variable Into A Regex In Perl?

Jan 17, 2010

I was wondering if you insert a variable into a regex in Perl, will the contents of the variable be expanded by the regex engine?

View 14 Replies View Related

Programming :: Perl - Regex With Array Elements?

Mar 13, 2011

I have .txt.gz files that store queries made on a browser, d my job is to analyze them.The information is stored in a xml-like style.Quote:

<browser>lwp-trivial/1.41</browser>
<http_code>200</http_code>
<keywords />

[code]...

View 6 Replies View Related

Programming :: Include A String Variable In A Regex (Perl)

Jan 9, 2010

how do you include a string variable as part of a regex in Perl?

View 5 Replies View Related

Programming :: Use Perl Regex To Extract The Hostname From A FQDN?

Nov 19, 2010

How do i use perl regex to extract the hostname from a FQDN?

I have

Quote:

$host=ganymede.a.linux.com
$host=io.a.linux.com
$host=europa.a.linux.com

i just want the characters which are to the left of the first .(dot) in FQDN name. I could get it using substr and split function,but how do i get it through regex.

View 13 Replies View Related

Programming :: Perl Only Matching Single-character Regex Patterns?

Jan 20, 2009

I'm having a small issue with regex matching in Perl. I'm pretty certain it's a simple fix, but it all looks correct to me...

If I run the following:

Code:

It prints out all the lines containing a 'P', as one would expect. But when the regex is

Code:

I get zero lines printed. It seems to match only single-character patterns.

The file I'm reading is: (It has the same effect whether I leave it with Windows linebreaks or convert them to unix).

Code:

View 3 Replies View Related

Programming :: Perl Regex Not Matching Across Multiple Lines Despite Ms Flags / Fix It?

Aug 16, 2010

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?)

View 14 Replies View Related

Programming :: Use Regex In Perl Script To Detect Allowed Words From The File And Then Print Output To The Screen?

Oct 4, 2010

Its my first post in here so please be patient I am trying to use regex in perl script to detect allowed words from the file and then print output to the screen.

As an example : I have text file with orders and returns :

Item2-SKU-2-11.08.2010-online
Item3-SKU-3-11.09.2010-return
Item4-SKU-4-11.09.2010-store

My question: is it possible to make sure that i am ony outputing to the screen orders based on few conditions like Item,order form e.g. online.And is it possible to have multiple matches (Item2 only diplay if ordered online etc)

View 1 Replies View Related

Programming :: Perl - Stop Range Search At End Of An Array?

Dec 7, 2010

I have data that looks similar to this -

Quote:

John Smith (Address)
123 Main St
Unit 1

[code].....

So I need everything between each name, but I am not guaranteed that each time I match a name that I will have the same amount of lines, so I do a range pattern search line this to get all lines, no matter if there is 5 or 10 or 15. I simply do a loop that goes through the whole array until I hit the match, and this is my search pattern.

Code:

if ($LINE =~ /^s+$SELECTED_NAME/ ... $LINE =~ /(Address)/) {
push @ADDRESS_INFO, $LINE;
}

This works perfectly... until I hit the end and it doesn't get its final pattern match because it's at the end and there is no next entry with a (Address) line. So as a 'hack', I ended up inserting a final scalar at the end of the array that just says (Address) so it knows it's at the end. Ideally though, I'd like to do an "or" statement that says search for Address || return true if I hit the end of the array. How would I match on "End Of Array" essentially?

View 1 Replies View Related

Programming :: Delete A Specific Range Of Files?

Aug 13, 2010

I have 50 files in the following format.

fileone.0001.txt
filetwo.0002.txt
filethree.0003.txt

[code]...

View 4 Replies View Related

Server :: Perl Program To Filter Emails For Specific Rules

Feb 4, 2010

Please what will it take me to write a perl full functioning program to filter emails for specific rules? Will that be possible? The actual thing am trying to get is to write a perl program and attach to a mail server so that, when the mails come in, the perl script get call and then the perl program will let another external program that is not on the server run and check or filter the mails.

View 8 Replies View Related

Networking :: What Are Short Range Link And Long Range Links In Routing

Jun 23, 2009

get me understand the short range and the long range links from routing (and routing protocols') point of view.

View 6 Replies View Related

Software :: Gnuplot - Combining A Linear Range And Log-scale Range In The Same X-axis?

Apr 24, 2011

I want to plot a set of data in only one plot.The problem is that some points of the data should be better plotted in a linear scale (lets say 0 to 100,000) but there are other data points that, exceding the value 100,000, would be better plotted in a logarithmic scale, as they goes in the range 100,000 to 500,000,000. Let's say the data is:

Code:

X Y
0 100
10000 80
20000 75

[code]....

Is there a way to plot all these points in the same plot in only one X-axis showing two different ranges in that axis: linear: 0-100,000 logarithmic: 100,000 - 1,000,000,000?The axis would be read, for example, as:

Code:
|-----|-----|-----|-----|-----|-----|-----|-----|-----|
0 20k 40k 60k 80k 100k 1M 10M 100M 1G

(The abbreviations k-M-G are not the important point. Just shown for clarity)

View 2 Replies View Related

General :: Change A Specific Characters To Capital In A Specific Text?

Dec 2, 2010

for example

else {
for fileDOC in $location/*.doc
do

[code]...

View 12 Replies View Related

General :: Awk/regex With A Post?

Apr 2, 2010

I have a data file with the following format 0 i j # # # # with other random lines of text to be filtered out.The following script works when there aren't many #s, but it shuffles long lists of data.

/^0/ {
split($0,token)
printf("%s %s ", $2, $3)

[code]...

View 4 Replies View Related

Programming :: Bash Script To Ping A Range Or Own IP-range?

Apr 11, 2011

I want to build a bash script, which can ping a range IP adresses which will be filled in by the admin. If there is no IP-adress filled in, then the script must ping the subnet where the system is logged on. So if my ip is 192.168.1.6, then the script must ping from 192.168.1.1 till 192.168.1.255 Or else, if there is given a beginning and ending ip it must ping that!

The first part of the bash script is to ping a given range (see below). But there is one problem, how can I tell the script to ping from $begin till $end, [..] is of course wrong! But what must be filled in there???

echo "Enter beginning IP-adres:"
read begin
echo "Enter ending IP-adres:"
read end
ping -c 1 $begin [..] $end

The second part is to find my own ip and ping the whole range.. How to do that? I only can find my own IP, but I cant ping the whole range,, how to do that?

#!/bin/bash
ifconfig | grep 'inet addr:' | grep -v '127.0.0.1' |
cut -d: -f2 | awk '{ print $1 }'

View 11 Replies View Related

General :: Which Regex Standard Is Used In Grep?

Apr 12, 2011

I'm wondering if it's POSIX + ASCII or something else is mixed in?

View 1 Replies View Related

General :: Regex Edit In Skype?

Jan 13, 2010

I am not a big skype user, but I was chatting with my sister, made a typo and habitually typed

tpyo
s/tpyo/typo/

to my surprise it actually changed the history. I am using the linux skype client 2.1.0.47-r1 and my sister is using 4.something on windows.

When she tried to do the same thing, it didn't work. Does anyone know if this is specific to the linux version?

View 1 Replies View Related

General :: Regex Escape The Comma?

Aug 12, 2010

sometimes there are one, sometime there are two exchanges in this log file. the 100= is the stock exchange- if there are two, they are seperated by a comma. i understand how to escape a comma in a regex, but I am having trouble with combining it.

35=8 39=1 38=1000 32=13 14=754 31=1.11 44=1.1 100=AMEX,ISE
35=8 39=1 38=1000 32=151 14=205 31=1.1 44=1.1 100=AMEX
35=U 39=2 38=1000 32=45 14=184 31=1.1 44=1.1 100=AMEX,ISE

[code]...

View 11 Replies View Related

General :: Sed Regex To Match Words Via A Pattern

Oct 24, 2010

I have some lines of text and I want to detect words that meet some criteria with sed.

E.g. The line "tetris cat dog test cactus stereotype"

I want to detect the word that contains two (2) ore more t letters. That mean the words tetris, test and stereotype.

The following regex doesn't do the job because it can;t distinguish words very well.

I thinks I have ti incorporate something like [^ ] in the regex but I wasn't successful...

View 3 Replies View Related

General :: Regex - Using Find To Locate Filenames Before A Certain Date?

Jul 11, 2011

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 Related

General :: Regex To Find Min / Max Length Words In File?

Jan 29, 2011

i 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?

View 4 Replies View Related

General :: Emacs - Search And Replace Regex In Multiple Buffers?

Apr 7, 2009

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.

View 2 Replies View Related

General :: Perform Action When Clipboard Contents Match Regex?

May 20, 2011

I use the Actions feature of KDE's Klipper utility to run certain commands when I copy something into the clipboard that matches a particular regular expression. Unfortunately, I have to turn on Enable Clipboard Actions and select the command from a menu every time I copy something that I want to run the command on. I'd like to have that command run automatically instead.

You'd think this was possible, as there is an automatic checkbox in the action settings dialog box:

Unfortunately, that appears to do nothing. The documentation included with Klipper does not indicate what that checkbox is supposed to do.

Is it possible to configure Klipper to run a command automatically if the contents of the clipboard matches a regular expression? If not, is there another way to accomplish this?

View 1 Replies View Related

General :: 'find' Command Regex To Exclude Hidden Files?

Jun 28, 2010

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 Related

General :: Command Line - Print A Group Of Text Matching A Regex?

Sep 22, 2011

I'd like to print only few groups from text matching a regex. How can I do that in the Linux command line?

What other tools for text processing are there in Linux?

View 3 Replies View Related

General :: Use "#!/usr/bin/perl" In The Beginning Of A Perl Script

Dec 17, 2010

I have a small problem with Perl and Apache.

If I use "#!/usr/bin/perl" in the beginning of a perl script the script won't work if the script is at all complicated. Simple scripts like "Hello World" works.

But if I use "#!/usr/bin/perl -w" in the beginning all scripts work?

If I don't use the -w this is whats in the logs:

(2)No such file or directory: exec of '/home/test.net/html/cgi-bin/uh/meny.pl' failed

Premature end of script headers: meny.pl

When I use the -w in the script the error-log shows me this.

meny.pl: Name "main::http_path_cgi" used only once: possible typo at /home/test.net/html/cgi-bin/uh/meny.pl line 24.

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved