I am very sorry . You are absolutely correct. I was trying to see whats going wrong and realized that my tool gave different XML than actual XML in file on filesystem .
So I tried to ran the sed for this XML set and it is not doing right. Might be we need alternative sed command:
<?xml version="1.0" encoding="utf-8"?>
<saw:ibot xmlns:saw="com.siebel.analytics.web/report/v1" version="1" priority="normal" jobID="36"><saw:schedule timeZoneId="(GMT-05:00) Eastern Time (US & Canada)" disabled="false"><saw:start repeatMinuteInterval="60" endTime="23:59:00" startImmediately="true"/><saw:recurrence runOnce="false"><saw:weekly weekInterval="1" mon="true" tue="true" wed="true" thu="true" fri="true"/></saw:recurrence></saw:schedule><saw:dataVisibility type="recipient" runAs="cgm"/><saw:choose><saw:when condition="true"><saw:deliveryContent><saw:headline><saw:caption><saw:text>Availability Parity Alert for Next 14 Days </saw:text></saw:caption></saw:headline><saw:conditionalReport/></saw:deliveryContent><saw:postActions/></saw:when><saw:otherwise/></saw:choose><saw:deliveryDestinations><saw:destination category="dashboard"/><saw:destination category="activeDeliveryProfile"/></saw:deliveryDestinations><saw:recipients subscribers="true" customize="false" specificRecipients="false"><saw:subscribers><saw:user name="mbussey@xyz.com" /><saw:user name="kimmy.chan@pqr.com" /><saw:user name="chudgins@gmail.com" /></saw:subscribers></saw:recipients><saw:conditionQuery><saw:reportRefNode path="/shared/Quote/Product/Alerts/Daily Availability Parity Alert - Next 14 Days - Content"/></saw:conditionQuery></saw:ibot>
Now quetion I have inputfile 1 , 2 ,3 all under dir1 .
So I want perl command to execute across all files under dir1 and give me results in redirected output file. Can we acheive this ?
I was trying in loop like belowand this indeed work but yours are much better...
now last and final question is I want unique list of emails in target output file. Anyway can we do that in your previous command ?
for FILENAME in $(find . -type f )
do
perl -nle '@mail = $_=~/saw:user name="(.*?)"/g and map {print "$_"} @mail' $FILENAME >> /home/orabi/final.txt
done;
pauldx, look a little closer to my last post #11, I explained that you do not need to use map, also I gave you a clue as how Perl can take care of reading any files under dir1 without the need to use a for loop.
If you still have issues understanding, please post the result of find . -type f . Make sure you use the proper tags when you post or the moderator, that has edited several time your posts, will get mad.
My apologize. I am new to the forum .
Sorry I mean I want to use your code below . But I need to understand how can I save outputfile using perl command below but need unique email list. I don't want to use |sort | uniq and I am sure we can achieve this in Perl
What you are asking, now, changes the command radically.
I do not like how messy is becoming as a one-liner. Here's a proper Perl script.
#!/usr/bin/perl
use strict;
use warnings;
my %emails;
while(my $line = <>) {
$emails{$_}++ for my @mail = $line =~ m/saw:user name="(.*?)"/g;
}
for my $email (sort keys %emails) {
print "$email\n";
}
And, if you going to use sort | uniq (after explicitly saying you didn't want to do that in post #14 in this thread), you could at least replace those two commands in your pipeline with just sort -u .