Sponsored Content
Full Discussion: How to execute Grep in Perl.
Top Forums Shell Programming and Scripting How to execute Grep in Perl. Post 302343876 by pludi on Friday 14th of August 2009 01:59:08 AM
Old 08-14-2009
Quote:
Originally Posted by jim mcnamara
[...]Coding this fully in perl with is a much larger endeavor....
Nope Smilie (Red: grep; Blue: sort; Green: uniq)
Code:
$ cat test_1
cdge-b-pas02.com 10.12.10.12
cdge-c-pas03.com 10.12.10.50
edge-a-pas01.com 10.12.10.11
cdge-d-pas03.com 10.12.10.10
edge-c-pas03.com 10.12.10.50
edge-d-pas03.com 10.12.10.10
edge-b-pas02.com 10.12.10.12
cdge-a-pas01.com 10.12.10.11
$ perl -se '@a=sort grep { /edge/ && !$seen{$_}++ } <>; print @a' test_1
edge-a-pas01.com 10.12.10.11
edge-b-pas02.com 10.12.10.12
edge-c-pas03.com 10.12.10.50
edge-d-pas03.com 10.12.10.10

This User Gave Thanks to pludi For This Post:
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

a cron job needs a perl script to execute

Hello evreyone, this is my first post, and to say i'm new to this is an understatement. I know very little about perl scripts and hope some one can help me. i'm looking to get a script that a cron job can execute. what the script needs to to is 1) connect to a mysql database 2) go to a... (2 Replies)
Discussion started by: Exader
2 Replies

2. Shell Programming and Scripting

How to execute java program from perl

hello all how can i run the java command that can eccept N numbers of args for example : java -cp .;foo.jar myApp 1 "ww" or java -cp .;foo.jar myApp 1 2 3 "ww" or java -cp .;foo.jar myApp "args1" "args2" "args3" Thanks (1 Reply)
Discussion started by: umen
1 Replies

3. Shell Programming and Scripting

Use grep result to execute next command

Hi I am trying to run 2 servers using a script one after the other. I start the first one: run.sh -c servername >> jboss_log.txt & Then I have to wait until I see Started message in the log file before I launch the other server. I can't use sleep because I am not sure how long it'll... (5 Replies)
Discussion started by: iririr
5 Replies

4. UNIX for Dummies Questions & Answers

Execute grep command within a folder

Experts, i need your help to made an enhance query using the existing one. i'm using a command "find . -exec grep -l 'search string' {} \;" to search a particular sting within the file within a folder. Basically, my idea is to fine tune my search. What i want is, instead of searching all files... (2 Replies)
Discussion started by: gav_dhiman
2 Replies

5. Shell Programming and Scripting

Execute in unix not in PERL

Hi All, This below command is working fine with unix box. However i could not able to run it in PERL. kidly suggest??? perl -ne '{push @x, $_}END{pop(@x); print @x}' create2.txt (15 Replies)
Discussion started by: adaleru
15 Replies

6. Shell Programming and Scripting

Perl Script to execute todays date.

Hi Folks, I have created a script last month to retrive files thru FTP and cronjob was running fine till yesterday. But the naming convention of the daily file is Filename_<date>.xml where date is YYYYMMDD. But today i have received file name as Filename_20110232.xml :( Part of my Perl... (4 Replies)
Discussion started by: Sendhil.Kumaran
4 Replies

7. Shell Programming and Scripting

execute ssh command via perl

Hi I have a perl command that doesn't seem to be working correctly. It appears to be fine but even when i try and run it manually same thing. Can someone take a look at this and tell me what they think the problem could be? Here is the perl Line: system ("echo 'ssh -t -t $user\@$_ \"cd... (3 Replies)
Discussion started by: vpundit
3 Replies

8. Shell Programming and Scripting

Execute immediate in perl script

hi All, i have to modify a shell script written in Perl. i have to use execute immediate within this. i have to create a temporary table but it should have name like ar_data_$mmyyyy , how can i achieve this? any help on this would be highly appriciated. (6 Replies)
Discussion started by: lovelysethii
6 Replies

9. Shell Programming and Scripting

[perl] execute remotely script

Hello Can some help with write part of perl script I need something like this in perl SSH="/bin/ssh -o BatchMode=yes -o" USER="test" SRV="server" SCRIPT_TO_EXEC="/tmp/test.sh" -> shell script OUT=/tmp/out.file ${SSH} -l ${USER} ${SRV} 'sudo /usr/bin/ksh -s' < ${SCRIPT_TO_EXEC} >> ${OUT}... (1 Reply)
Discussion started by: vikus
1 Replies

10. Programming

PERL: In a perl-scripttTrying to execute another perl-script that SETS SOME VARIABLES !

I have reviewed many examples on-line about running another process (either PERL or shell command or a program), but do not find any usefull for my needs way. (Reviewed and not useful the system(), 'back ticks', exec() and open()) I would like to run another PERL-script from first one, not... (1 Reply)
Discussion started by: alex_5161
1 Replies
Graph::Easy::Edge(3pm)					User Contributed Perl Documentation				    Graph::Easy::Edge(3pm)

NAME
Graph::Easy::Edge - An edge (a path connecting one ore more nodes) SYNOPSIS
use Graph::Easy; my $ssl = Graph::Easy::Edge->new( label => 'encrypted connection', style => 'solid', ); $ssl->set_attribute('color', 'red'); my $src = Graph::Easy::Node->new('source'); my $dst = Graph::Easy::Node->new('destination'); $graph = Graph::Easy->new(); $graph->add_edge($src, $dst, $ssl); print $graph->as_ascii(); DESCRIPTION
A "Graph::Easy::Edge" represents an edge between two (or more) nodes in a simple graph. Each edge has a direction (from source to destination, or back and forth), plus a style (line width and style), colors etc. It can also have a label, e.g. a text associated with it. During the layout phase, each edge also contains a list of path-elements (also called cells), which make up the path from source to destination. METHODS
error() $last_error = $edge->error(); $cvt->error($error); # set new messags $cvt->error(''); # clear error Returns the last error message, or '' for no error. as_ascii() my $ascii = $edge->as_ascii(); Returns the edge as a little ascii representation. as_txt() my $txt = $edge->as_txt(); Returns the edge as a little Graph::Easy textual representation. label() my $label = $edge->label(); Returns the label (also known as 'name') of the edge. name() my $label = $edge->name(); To make the interface more consistent, the "name()" method of an edge can also be called, and it will returned either the edge label, or the empty string if the edge doesn't have a label. style() my $style = $edge->style(); Returns the style of the edge, like 'solid', 'dotted', 'double', etc. nodes() my @nodes = $edge->nodes(); Returns the source and target node that this edges connects as objects. bidirectional() $edge->bidirectional(1); if ($edge->bidirectional()) { } Returns true if the edge is bidirectional, aka has arrow heads on both ends. An optional parameter will set the bidirectional status of the edge. undirected() $edge->undirected(1); if ($edge->undirected()) { } Returns true if the edge is undirected, aka has now arrow at all. An optional parameter will set the undirected status of the edge. has_ports() if ($edge->has_ports()) { ... } Return true if the edge has restriction on the starting or ending port, e.g. either the "start" or "end" attribute is set on this edge. start_port() my $port = $edge->start_port(); Return undef if the edge does not have a fixed start port, otherwise returns the port as "side, number", for example "south, 0". end_port() my $port = $edge->end_port(); Return undef if the edge does not have a fixed end port, otherwise returns the port as "side, number", for example "south, 0". from() my $from = $edge->from(); Returns the node that this edge starts at. See also "to()". to() my $to = $edge->to(); Returns the node that this edge leads to. See also "from()". start_at() $edge->start_at($other); my $other = $edge->start_at('some node'); Set the edge's start point to the given node. If given a node name, will add that node to the graph first. Returns the new edge start point node. end_at() $edge->end_at($other); my $other = $edge->end_at('some other node'); Set the edge's end point to the given node. If given a node name, will add that node to the graph first. Returns the new edge end point node. flip() $edge->flip(); Swaps the "start" and "end" nodes on this edge, e.g. reverses the direction of the edge. flow() my $flow = $edge->flow(); Returns the flow for this edge, honoring inheritance. An edge without a specific flow set will inherit the flow from the node it comes from. edge_flow() my $flow = $edge->edge_flow(); Returns the flow for this edge, or undef if it has none set on either the object itself or its class. port() my ($side, $number) = $edge->port('start'); my ($side, $number) = $edge->port('end'); Return the side and port number where this edge starts or ends. Returns undef for $side if the edge has no port restriction. The returned side will be one absolute direction of "east", "west", "north" or "south", depending on the port restriction and flow at that edge. get_attributes() my $att = $object->get_attributes(); Return all effective attributes on this object (graph/node/group/edge) as an anonymous hash ref. This respects inheritance and default values. See also raw_attributes(). raw_attributes() my $att = $object->get_attributes(); Return all set attributes on this object (graph/node/group/edge) as an anonymous hash ref. This respects inheritance, but does not include default values for unset attributes. See also get_attributes(). attribute related methods You can call all the various attribute related methods like "set_attribute()", "get_attribute()", etc. on an edge, too. For example: $edge->set_attribute('label', 'by train'); my $attr = $edge->get_attributes(); my $raw_attr = $edge->raw_attributes(); You can find more documentation in Graph::Easy. EXPORT
None by default. SEE ALSO
Graph::Easy. AUTHOR
Copyright (C) 2004 - 2008 by Tels <http://bloodgate.com>. See the LICENSE file for more details. perl v5.14.2 2011-12-23 Graph::Easy::Edge(3pm)
All times are GMT -4. The time now is 06:48 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy