You are using regex, not a shell glob. That would match 2012-04-1, since the 4 may be matched 0+ times. Drop the asterisks. or replace it with a space.
I've got a longish log file with content such as
Uplink traffic:
Downlink traffic:
I want to parse the log file and remove any line that contains the string "Uplink traffic:" at the beginning of the line, but only if the line following it beginnings with the string "Downlink traffic:" (in... (7 Replies)
I'm attempting to insert multiple lines before a line matching a given search pattern. These lines are generated in a separate function and can either be piped in as stdout or read from a temporary file.
I've been able to insert the lines from a file after the pattern using:
sed -i '/pattern/... (2 Replies)
Hi
I know sed and awk has options to give range of line numbers, but
I need to replace pattern in specific lines
Something like
sed -e '1s,14s,26s/pattern/new pattern/' file name
Can somebody help me in this....
I am fine with see/awk/perl
Thank you in advance (9 Replies)
Hi all,
I am new to using awk and am quickly discovering what a powerful pattern-recognition tool it is. However, I have what seems like a fairly basic task that I just can't figure out how to perform in one line. I want awk to find and print all the lines in which one of multiple patterns (e.g.... (8 Replies)
Dear Unix Forums,
I am hoping you can help me with a pattern matching problem.
What am I trying to do?
I want to replace multiple lines of a text file (that match a multi-line pattern) with a single line of text. These patterns can span several lines and do not always have the same number of... (10 Replies)
'Hi
I'm using the following code to extract the lines(and redirect them to a txt file) after the pattern match. But the output is inclusive of the line with pattern match.
Which option is to be used to exclude the line containing the pattern?
sed -n '/Conn.*User/,$p' > consumers.txt (11 Replies)
Hi All
I am having one awk and sed requirement for the below problem.
I tried multiple options in my sed or awk and right output is not coming out.
Problem Description
###############################################################
I am having a big file say file having repeated... (4 Replies)
I have the below plain text file where i have some result, in order to mail that result in html table format I have written the below script and its working well. cat result.txt
Page 2015-01-01 2000
Colors 2015-02-01 3000
Landing 2015-03-02 4000
#!/bin/sh LOG=/tmp/maillog.txt... (1 Reply)
Hi Folks,
I have a file with fields as follows which has last field in multiple lines. I would like to combine a line which has three fields with single field line for as shown in expected output. Please help.
INPUT
hname01 windows appnamec1eda_p1, ... (5 Replies)
Hi Guys,
I am trying to format my csv file. When I spool the file using sqlplus the single row output is wrapped on three lines.
Somehow I managed to format that file and finally i am trying to make the multiple line on single line.
The below command is working fine but I need to pass the... (3 Replies)
Discussion started by: RJSKR28
3 Replies
LEARN ABOUT OSX
text::glob
Text::Glob(3) User Contributed Perl Documentation Text::Glob(3)NAME
Text::Glob - match globbing patterns against text
SYNOPSIS
use Text::Glob qw( match_glob glob_to_regex );
print "matched
" if match_glob( "foo.*", "foo.bar" );
# prints foo.bar and foo.baz
my $regex = glob_to_regex( "foo.*" );
for ( qw( foo.bar foo.baz foo bar ) ) {
print "matched: $_
" if /$regex/;
}
DESCRIPTION
Text::Glob implements glob(3) style matching that can be used to match against text, rather than fetching names from a filesystem. If you
want to do full file globbing use the File::Glob module instead.
Routines
match_glob( $glob, @things_to_test )
Returns the list of things which match the glob from the source list.
glob_to_regex( $glob )
Returns a compiled regex which is the equivalent of the globbing pattern.
glob_to_regex_string( $glob )
Returns a regex string which is the equivalent of the globbing pattern.
SYNTAX
The following metacharacters and rules are respected.
"*" - match zero or more characters
"a*" matches "a", "aa", "aaaa" and many many more.
"?" - match exactly one character
"a?" matches "aa", but not "a", or "aaa"
Character sets/ranges
"example.[ch]" matches "example.c" and "example.h"
"demo.[a-c]" matches "demo.a", "demo.b", and "demo.c"
alternation
"example.{foo,bar,baz}" matches "example.foo", "example.bar", and "example.baz"
leading . must be explictly matched
"*.foo" does not match ".bar.foo". For this you must either specify the leading . in the glob pattern (".*.foo"), or set
$Text::Glob::strict_leading_dot to a false value while compiling the regex.
"*" and "?" do not match /
"*.foo" does not match "bar/baz.foo". For this you must either explicitly match the / in the glob ("*/*.foo"), or set
$Text::Glob::strict_wildcard_slash to a false value with compiling the regex.
BUGS
The code uses qr// to produce compiled regexes, therefore this module requires perl version 5.005_03 or newer.
AUTHOR
Richard Clamp <richardc@unixbeard.net>
COPYRIGHT
Copyright (C) 2002, 2003, 2006, 2007 Richard Clamp. All Rights Reserved.
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
SEE ALSO
File::Glob, glob(3)perl v5.16.2 2013-08-25 Text::Glob(3)