Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Deleting all but a regex using sed, tr, cut etc Post 302550892 by Pureferret on Sunday 28th of August 2011 12:28:28 PM
Old 08-28-2011
Thanks Yazu I'll give it a go, I think I can see whats happening.

Xbin, really struggling to see what you've done...Smilie
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

sed regex

I would like to do this: replace the word "prod" with the word "special" but it may occur through the file naturally without a command, I only want it to happen when it has a specific command in front of it. The command will always look like this <IMG,###,###,##,>prod/directory/IMG/file ... (4 Replies)
Discussion started by: Shakey21
4 Replies

2. Shell Programming and Scripting

Sed and regex help needed

Hi all, I'm writing a script that replaces a value in a file. The file is formatted as follows: So, for this example, I'd like to replace the value for param_two. The value for param_two can be a one, or two-digit number. It replaces the value in file.cfg, and directs the... (9 Replies)
Discussion started by: marknu1
9 Replies

3. Shell Programming and Scripting

sed - using regex and | need help

From my understanding when using regex1|regex2 the matching process tries each alternative in turn, from left to right, and the first one that succeeds is used. When im trying to extract the name from those examples: A) name.can.be.different.20.03.2009.boom B)... (2 Replies)
Discussion started by: TehOne
2 Replies

4. Shell Programming and Scripting

deleting text records with sed (sed paragraphs)

Hi all, First off, Thank you all for the knowledge I have gleaned from this site! Deleting Records from a text file... sed paragraphs The following code works nearly perfect, however each time it is run on the log file it adds a newline at the head of the file, run it 5 times, it'll have 5... (1 Reply)
Discussion started by: Festus Hagen
1 Replies

5. Shell Programming and Scripting

perl regex multi line cut

hello mighty all there's a file with lots of comments.. some of them looks like: =comment blabla blablabla bla =cut i'm trying to cut this out completely with this code: $line=~s/^=.+?=cut//sg; but no luck also tryed to change it abit but still I don't understand how the... (9 Replies)
Discussion started by: tip78
9 Replies

6. Shell Programming and Scripting

Converting perl regex to sed regex

I am having trouble parsing rpm filenames in a shell script.. I found a snippet of perl code that will perform the task but I really don't have time to rewrite the entire script in perl. I cannot for the life of me convert this code into something sed-friendly: if ($rpm =~ /(*)-(*)-(*)\.(.*)/)... (1 Reply)
Discussion started by: suntzu
1 Replies

7. UNIX for Advanced & Expert Users

Sed regex problem

Hi, I tried to extract the time from `date` with sed. (I know it works with `date +%H:%M:%S` as well) I got three solutions of which just one worked. I thought "+" should repeat the previous expression 1 or more times and {n} should repeat the previous expression n times. $ date Thu... (9 Replies)
Discussion started by: thiuda
9 Replies

8. Shell Programming and Scripting

Help with sed substitution / regex

Hi all, please can anyone show me how to use sed and regular expressions to achieve the following. If a line contains a capital A followed by exactly 5 or 6 characters followed by an angled bracket then insert an asterix before the angled bracket. So: XCONFIGA12345<X Becomes: ... (5 Replies)
Discussion started by: Jedimark
5 Replies

9. Shell Programming and Scripting

Multiple regex in sed

I am using the following sed script to remove new lines (\r\n and \n), except from lines starting with >: sed -i ':a /^>/!N;s/\r\n\(\)/\1/;s/\n\(\)/\1/;ta' Is there a way to include both \r\n and \n in one regex to avoid the second substitute script (s/\n\(\)/\1/)? (4 Replies)
Discussion started by: Xterra
4 Replies

10. Shell Programming and Scripting

Regex with sed

hi i would like to say "DATABASENAME=" to "TABLESNAME=" remove "," and press enter myconfig file thanks (1 Reply)
Discussion started by: mnnn
1 Replies
OpenGuides::Search(3pm) 				User Contributed Perl Documentation				   OpenGuides::Search(3pm)

NAME
OpenGuides::Search - Search form generation and processing for OpenGuides. DESCRIPTION
Does search stuff for OpenGuides. Distributed and installed as part of the OpenGuides project, not intended for independent installation. This documentation is probably only useful to OpenGuides developers. SYNOPSIS
use CGI; use OpenGuides::Config; use OpenGuides::Search; my $config = OpenGuides::Config->new( file => "wiki.conf" ); my $search = OpenGuides::Search->new( config => $config ); my %vars = CGI::Vars(); $search->run( vars => \%vars ); METHODS
new my $config = OpenGuides::Config->new( file => "wiki.conf" ); my $search = OpenGuides::Search->new( config => $config ); wiki my $wiki = $search->wiki; An accessor; returns the underlying Wiki::Toolkit object. config my $config = $search->config; An accessor; returns the underlying OpenGuides::Config object. run my %vars = CGI::Vars(); $search->run( vars => \%vars, return_output => 1, # defaults to 0 return_tt_vars => 1, # defaults to 0 ); The "return_output" parameter is optional. If supplied and true, the stuff that would normally be printed to STDOUT will be returned as a string instead. The "return_tt_vars" parameter is also optional. If supplied and true, the template is not processed and the variables that would have been passed to it are returned as a hash. This parameter takes precedence over "return_output". These two parameters exist to make testing easier; you probably don't want to use them in production. You can also request just the raw search results: my %results = $search->run( os_x => 528864, os_y => 180797, os_dist => 750, format => "raw", ); Results are returned as a hash, keyed on the page name. All results are returned, not just the first "page". The values in the hash are hashes themselves, with the following key/value pairs: o name o wgs84_lat - WGS-84 latitude o wgs84_long - WGS-84 longitude o summary o distance - distance (in metres) from origin, if origin exists o score - relevance to search string, if search string exists; higher score means more relevance In case you're struggling to follow the code, it does the following: 1) Processes the parameters, and bails out if it hit a problem with them 2) If a search string was given, do a text search 3) If distance search paramaters were given, do a distance search 4) If no search has occured, print out the search form 5) If an error occured, bail out 6) If we got a single hit on a string search, redirect to it 7) If no results were found, give an empty search results page 8) Sort the results by either score or distance 9) Decide which results to show, based on paging 10) Display the appropriate page of the results INPUT
word a single word will be matched as-is. For example, a search on escalator will return all pages containing the word "escalator". AND searches A list of words with no punctuation will be ANDed, for example: restaurant vegetarian will return all pages containing both the word "restaurant" and the word "vegetarian". OR searches A list of words separated by commas (and optional spaces) will be ORed, for example: restaurant, cafe will return all pages containing either the word "restaurant" or the word "cafe". phrase searches Enclose phrases in double quotes, for example: "meat pie" will return all pages that contain the exact phrase "meat pie" - not pages that only contain, for example, "apple pie and meat sausage". SEARCHING BY DISTANCE
To perform a distance search, you need to supply one of the following sets of criteria to specify the distance to search within, and the origin (centre) of the search: os_dist, os_x, and os_y Only works if you chose to use British National Grid in wiki.conf osie_dist, osie_x, and osie_y Only works if you chose to use Irish National Grid in wiki.conf latlong_dist, latitude, and longitude Should always work, but has a habit of "finding" things a couple of metres away from themselves. You can perform both pure distance searches and distance searches in combination with text searches. OUTPUT
Results will be put into some form of relevance ordering. These are the rules we have tests for so far (and hence the only rules that can be relied on): o A match on page title will score higher than a match on page category or locale. o A match on page category or locale will score higher than a match on page content. o Two matches in the title beats one match in the title and one in the content. AUTHOR
The OpenGuides Project (openguides-dev@lists.openguides.org) COPYRIGHT
Copyright (C) 2003-2008 The OpenGuides Project. All Rights Reserved. The OpenGuides distribution is free software; you can redistribute it and/or modify it under the same terms as Perl itself. SEE ALSO
OpenGuides perl v5.14.2 2013-01-11 OpenGuides::Search(3pm)
All times are GMT -4. The time now is 02:41 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy