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


ADVERTISEMENT

General :: Add (not Replacing) A Pattern Match With A Similar Pattern?

Aug 30, 2009

I'm writing a bash script to search html files, and when I find any occurrence of an img src tag like this:

<img src="123-picture-normal.jpg" alt="some random user entered text" border="0">

I want to add a second line below it that looks like:
<img src="123-picture-thumbnail.jpg" alt="some random user entered text" border="0">

All I need to do is duplicate the line but replace "normal" with "thumbnail"

Each file can have multiple img src tags with different numbered jpgs.

I have a feeling this is a job for sed, but I'm struggling with it. Any ideas?

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 :: 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 :: Use Sed To Delete All Lines Before First Match Of A Pattern?

Apr 14, 2010

I have to use sed with this problem, and sed is extremely complicated, they could probably teach a whole class on this entire function.

Here's an example to show what I need to do:

Code...

how would I say that every line before I reach the first match of "sweet" should be deleted so that the output will look like: Code...

View 9 Replies View Related

General :: Use Sed In Bash To Match Pattern Contained In 2 Lines?

Mar 14, 2011

I have a file called test. It has the following contents.Code:there youI want the output to be.Code:replaced youI am trying to use the sed command to replace every occurance of "hey newline there" with "replaced". I tried the following naive apporach.Code:sed 's/heythere/replace/' testThis gives a result containing the same data as the test file.

View 3 Replies View Related

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

Ubuntu :: Text Manipulation - Regex - Pattern Matching?

Jul 12, 2010

Are there some good tutorials or reference materials on how do pattern matching and text manipulation in Linux?I have a few simple tasks I'd like taken care of...like formatting numbers in file names, stripping some text from directory names, etc

View 2 Replies View Related

Ubuntu :: Regex In Grep - Match With Any Character Combination

Dec 10, 2010

regex in grep? I need to match ANYTHING in the following with any character combination (something like * in findstr in C): grep "Delivery of nonspam" /var/log/mail.log | grep "to [URL]"

View 1 Replies View Related

Programming :: If Statement Regex Match For White Spaces?

Apr 8, 2011

I want to match for this string:

Code:

Content-Transfer-Encoding:[:space:]base64
Content-Disposition:[:space:]attachment;[:space:]filename="%variable%"

Both lines are new lines, so they won't be inline. Other than that, they are all constants, I want this regex match to be an if statement rather than returning match string. so if the $content variable contains some string that matches:

Code:

if `sed "//p"` ;

View 4 Replies View Related

Programming :: Find A Proper Regex To Match The Two Numbers?

Nov 10, 2010

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;

View 6 Replies View Related

Programming :: Sed Regex Get Multiple String Match In Array?

Apr 8, 2011

I 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

View 3 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 :: Use Of Uninitialized Value In Pattern Match - Perl

Jun 26, 2011

I want to strip the process name from the hosts - i did it with the code below.

I have two questions - is there a more compact way to strip off the process names? usalso i want to get rid of the errors after extracting the hostname. It is complaing about $arry[1]. using my $arry[1] is not allowed. Assigning the slice to a value, as is 'my $sliced_arry = $arry[1]; print $sliced_arry , does not work either.

Code:

Use of uninitialized value in pattern match (m//) at newcomm_stats.pl3 line 7, <NEWCOMM> line 16 here i get what i want - just the host name, but still get those nasty errors. assigning a value to $1 does not work, and localizing $1 with 'my' is not allowed.

Code:

View 4 Replies View Related

Slackware :: No Packages Match The Pattern For Install?

Aug 10, 2010

seemed to have buggered up installing netbeans on my slackware 13.0 machine. I got the source (the zip file), which i copied into the extracted slackbuild, then did a

Code:
./netbeans.SlackBuild

It all seemed to work fine, at the end it told me my package could be found in /tmp. So i went there and did a

Code: root@slackLap:/tmp# slackpkg install netbeans-6.8-i586-1_SBo.tgz

Looking for netbeans-6.8-i586-1_SBo.tgz in package list. Please wait... DONE

No packages match the pattern for install. Try: /usr/sbin/slackpkg reinstall|upgrade

ps i'm running 32bit slackware 13.0

View 3 Replies View Related

Programming :: File Renaming Based On A Pattern Match

Jan 8, 2011

What I am attempting to do is rename some television shows into the format that my PVR will understand for the naming convention. I have a script that cleans them up about 95%, now I just cant figure out the last little detail..

For example: NCIS_01.mkv
I think it can be done in sed, but I just figure out how. I need it to be renamed to: NCIS_s01e01.mkv

How can I make sed (or something else) match the last "_" and any numbers after it until the period and then insert text between them reliably?

Depending on the show, it can be something like: This_show_name_243.avi so I need it to be more flexible than I can figure out how to do..

View 6 Replies View Related

Ubuntu :: Getting Grep To Pull Info From A Specific File Which Match All The Words?

Jun 2, 2011

I am trying to use grep to only tell me files that include both words matching in a pattern file. However when i specify:

grep -f <pattern file> <file>

It pulls out anything that matches one or the other.

Not both.

how to get it to match AND not OR.

View 9 Replies View Related

Programming :: Match "euro" Signe Using Regex In Php?

Feb 15, 2010

I'm looking at a way to match the "euro" signe in my php code
below is my code which doesn't work:

Code...
so in clear word I would like to change the "�" above with the hexadecimal or unicode value.

1. How can I use hexa or unicode in regex to match special characters?
2. Does anyone have a link where I can find these tables?

View 1 Replies View Related

General :: Find Pattern After Specific Pattern

Oct 11, 2010

I want to go through a log file and find pattern1 and then a pattern2 only after pattern 1.So for example I want to know howManyRecords was in 13:30.I figured I grep for "start time for the job" and then only after that (and before the next occurence of that) grep for "howManyRecords". Is this a sane way?

View 1 Replies View Related

Programming :: Search A File For A Particular Pattern And If Pattern Found Replace The Line With New Text?

Feb 24, 2010

I want to search a file for a particular pattern and if pattern found replace the line with new text. i am using awk 'match($0,"pattern") != 0 {print $0} ' filename to check if the pattern exists.how do i get the line number of the pattern and delete that line and replace the line with my new text?

View 1 Replies View Related

Programming :: If Statement Pattern Search / End Of Pattern Special Character?

Apr 29, 2010

I have to enhance the behaviour of a backup script written in perl. I don't need to change it, what I need to do is to create a bash script that does some checks like file name and file size, execute the backup script then check if the backup files match the original files.Here's how I try to do it:

- read the files from the original files folder
- store them in an array
- search in the array the files that have a specific file extension
- store the file names that match the search pattern (I know the backup script skips some files so I can hardcode the search pattern)
- run the backup script
- read the files from the backup folder
- store them in an array
- compare the original files name and size stored in an array with those from the backup folder
- send a report email

View 3 Replies View Related

Programming :: Match Datetime By The Minute (not An Exact Match By The Second)

Oct 21, 2010

I have the following query:

Code:
$sql="SELECT table1.datetime, table1.user_id, table2.ip, FROM table1,table2 WHERE id='$id' AND (table1.id = table2.id AND table1.datetime = table2.datetime)";

In table2 the datetime fields are about 1 to 2 seconds off due to the source of the data, which I cannot change.

Is it possible via a query match table1.datetime & table2.datetime by HH:MM (ie. to the minute instead of to the second)?

View 1 Replies View Related

Software :: Replace Newline Pattern In File By Other Newline Pattern In A Shell Script?

Nov 22, 2010

I have several (vhdl) files containing a pattern with newline characters that I need to replace by another pattern that also contains newline characters.

I start with something like:

Code:

I want to replace it by something like:

Code:

(I need to paste some lines)

As I need to do this (very) often I want to use a shell script.

I tried:

1.

Code:

result:

Code:

2.

Code:

result:

File remains unchanged

3.

Code:

result:

Code:

4.

Code:

result:

Displays the unchanged testfile

How I can automate the pattern replacement?

Code:

View 9 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

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 :: 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 :: GREP On Words With 2 Or More Z's?

Dec 21, 2010

I need to grep a dictionary file.Only the words that contain 2 or more z's and only 1 b needs to be listed.

View 1 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







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