no, because you're overwriting the the whole record/line on every iteration through the 'while' loop - chopping it up to 'nothing' with 'match' and the '$0=...' assignment.
An alternative - holding on to the FIRST 'before' pattern and printing it out for every 'match':
HELP!!!! I am in an on-line shell programming class and have a question. Here is the data:
Mike Harrington:(510) 548-1278:250:100:175
Christian Dobbins:(408) 538-2358:155:90:201
Susan Dalsass:(206) 654-6279:250:60:50
(There are 12 contribuors total)
This database contains names, phone... (1 Reply)
Hi All,
I am using solaris and nawk.
Is there any time function in nawk which is simliar to the shell `date` function ?
Can any experts show any examples? (4 Replies)
Hi,
I am using a Solaris OS here. My intention is to print the 2nd field if the first field matches "APPLE=". I am using the "getline" function here (shown below), but it doesn;t work. Can any experts give me some advice?
Input:
ORANGE= 10
APPLE= 20
MANGO= 30
GRAPES= 40
Output:
20
... (5 Replies)
i am matching two files.
the files are in the format
file_1.txt
1|_|X|_|
2|_|W|_|
3|_|Y|_|
4|_|Z|_|
5|_|U|_|
file_2.txt
W|_|A|_|
Z|_|C|_|
V|_|B|_|
X|_|D|_|sdff|_|
Y|_|
file_3.txt should be in the format (4 Replies)
I am scanning a file (line by line) for format errors. A line could have multiple errors. Each field in the line is evaluated for errors and sent, along w/ any error messages, to a temporary file. Finally, if any errors were detected, this temporary file is then appended to the errorFile. The... (4 Replies)
I am new to scripting and this is probably the 4th or 5th simple script I have written. I am working with a HUGE number of data that need to be organized into folders and named a certain way. I wrote the naming script using a while function to go through the 1000-some folders and rename the files... (0 Replies)
Hi,
I just need to check whether number of digits in a phone number is 10 or not. If I am not wrong regex will be: {9}
I have to use this inside nawk as this is a small portion of a big program.
nawk '
BEGIN { RS="";FS=";";
regex="{9}";
}
{
for (i=1;i<=NF;i++) {
if... (6 Replies)
I have a file with the contents below "lets say the name of the file is abcxyz" shown at the end of this.
I am using nawk to find the exact ip address and the 6 lines after the match is found using the following nawk statement
/usr/bin/nawk "/111.46.14.107/,printed==6 { ++printed; print; }"... (7 Replies)
Using a bash for loop to pass variables into a nawk loop to capture a string in an sftp log. Tried several different syntax methods to have the variable treated as a regex so the loop will capture the string.
for i in `cat /tmp/dar3.out.2`
do
nawk -vst=$i '$5 ~ /$st/ && /closed/ && /user/... (3 Replies)
Hi
I am using Solaris 5.10 & ksh
Wanted to loop through a pattern file by reading it and passing it to the awk to match that value present in column 1 of rawdata.txt , if so print column 1 & 2 in to Avlblpatterns.txt. Using the following code but it seems some mistakes and it is running for... (2 Replies)
Discussion started by: ananan
2 Replies
LEARN ABOUT DEBIAN
mousex::nativetraits::str
MouseX::NativeTraits::Str(3pm) User Contributed Perl Documentation MouseX::NativeTraits::Str(3pm)NAME
MouseX::NativeTraits::Str - Helper trait for Str attributes
SYNOPSIS
package MyHomePage;
use Mouse;
has 'text' => (
traits => ['String'],
is => 'rw',
isa => 'Str',
default => q{},
handles => {
add_text => 'append',
replace_text => 'replace',
},
);
my $page = MyHomePage->new();
$page->add_text("foo"); # same as $page->text($page->text . "foo");
DESCRIPTION
This module provides a simple string attribute, to which mutating string operations can be applied more easily (no need to make an lvalue
attribute metaclass or use temporary variables). Additional methods are provided for completion.
PROVIDED METHODS
These methods are implemented in MouseX::NativeTraits::MethodProvider::Str. It is important to note that all those methods do in place
modification of the value stored in the attribute.
inc Increments the value stored in this slot using the magical string autoincrement operator. Note that Perl doesn't provide analogous
behavior in "--", so "dec" is not available.
append($string)
Append a string, like ".=".
prepend($string)
Prepend a string.
replace($pattern, $replacement)
Performs a regexp substitution ("s" in perlop). A code references will be accepted for the replacement, causing the regexp to be
modified with a single "e". "/smxi" can be applied using the "qr" operator.
replace($pattern, $replacement)
Performs a regexp substitution ("s" in perlop) with the "g" flag. A code references will be accepted for the replacement, causing the
regexp to be modified with a single "e". "/smxi" can be applied using the "qr" operator.
match($pattern)
Like "replace" but without the replacement. Provided mostly for completeness.
chop
"chop" in perlfunc
chomp
"chomp" in perlfunc
clear
Sets the string to the empty string (not the value passed to "default").
length
"length" in perlfunc
substr
"substr" in perlfunc. We go to some lengths to match the different functionality based on "substr"'s arity.
METHODS
meta
method_provider_class
helper_type
SEE ALSO
MouseX::NativeTraits
perl v5.14.2 2011-12-04 MouseX::NativeTraits::Str(3pm)