Sponsored Content
Full Discussion: File not found using find
Top Forums UNIX for Dummies Questions & Answers File not found using find Post 302448873 by zaxxon on Friday 27th of August 2010 08:55:26 AM
Old 08-27-2010
Often it is not needed but if you add a -print to the end?

Can you fire off a
Code:
stat ./processed/test99

?
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Help with find command and list in a long format each found file

The purpose of those comands are to find the newest file in a directory acvrdind to system date, and it has to be recursively found in each directory. The problem is that i want to list in a long format every found file, but the commands i use produce unexpected results ,so the output lists in a... (5 Replies)
Discussion started by: alexcol
5 Replies

2. UNIX for Dummies Questions & Answers

find and remove rows from file where multi occurrences of character found

I have a '~' delimited file of 6 - 7 million rows. Each row should contain 13 columns delimited by 12 ~'s. Where there are 13 tildes, the row needs to be removed. Each row contains alphanumeric data and occasionally a ~ ends up in a descriptive field and therefore acts as a delimiter, resulting in... (1 Reply)
Discussion started by: kpd
1 Replies

3. Shell Programming and Scripting

find a value in a file and echo if found

I need to awk a value out of a file and see if it exists in another file. My if statement below returns a positive even if the value doesn't exist. The kky3 is finding the correct field for the value. cat $PRE | while read a do kky2=`echo $a | awk -F: '{print $2}'` echo "kky2 "... (5 Replies)
Discussion started by: MizzGail
5 Replies

4. Shell Programming and Scripting

To find the line no, where the particular pattern is not found

Hi, suppose i have a txt file containing thye following data 2012156|sb3|nwknjps|BAYONNE|NJ|tcg 201221|094|mtnnjprc:HACKENSACK|NJ|tcg 201222|wn3|mtnnjtc|HACKENSACK|NJ|tcg 2018164|ik4|mtnntc|JERSEY CITY|NJ|tcg 20123482|ik4|mtnnjpritc,JERSEY CITY|NJ|tcg... (3 Replies)
Discussion started by: priyanka3006
3 Replies

5. UNIX for Dummies Questions & Answers

Using find -d and copying to the found directories

Hi again All :) After posting my first thread just a few eeks ago and having such a great response (Thank You once again :) ), I thought I'd perhaps ask the experts again. In short I'm trying to achieve a "find" and "copy" where the find needs to find directories: find -d -name outbox and... (6 Replies)
Discussion started by: Dean Rotherham
6 Replies

6. Shell Programming and Scripting

find with xargs to rm found files

I believe what is happening is rm is executing in the script on every directory and on failure of the first it stops although returns status 0. find $HOME -name /directory/filename | xargs -l rm This is the code I use but file remains. I am using sun solaris system which has way limited... (4 Replies)
Discussion started by: Ebodee
4 Replies

7. Linux

Find String in FileName and move the String to new File if not found

Hi all, I have a question.. Here is my requirement..I have 500 files in a path say /a/b/c I have some numbers in a file which are comma seperated...and I wanted to check if the numbers are present in the FileName in the path /a/b/c..if the number is there in the file that is fine..but if... (1 Reply)
Discussion started by: us_pokiri
1 Replies

8. UNIX for Dummies Questions & Answers

How to find a file based on pattern & return the filename if found?

Hi all, I am a newbie here. I have this requirement to find a file based on a pattern then return the filename if found. I created a script based on online tutorials. Though, I am stuck & really appreciate if anyone can have a quick look & point me to the right direction? #Script starts... (10 Replies)
Discussion started by: buster_t
10 Replies

9. Shell Programming and Scripting

Find header in a text file and prepend it to all lines until another header is found

I've been struggling with this one for quite a while and cannot seem to find a solution for this find/replace scenario. Perhaps I'm getting rusty. I have a file that contains a number of metrics (exactly 3 fields per line) from a few appliances that are collected in parallel. To identify the... (3 Replies)
Discussion started by: verdepollo
3 Replies

10. Shell Programming and Scripting

Assistance with my Find command to identify last part of a file name and report the name found

Hello Forum, We have two bootstraps of Chef in our environment which are identified by colour: /var/chef/cache/cookbooks/bootstrap_cookbooks_version_green and /var/chef/cache/cookbooks/bootstrap_cookbooks_version_red I'm attempting to identify which version is installed based on the name... (11 Replies)
Discussion started by: greavette
11 Replies
Aspect::Library::Listenable(3pm)			User Contributed Perl Documentation			  Aspect::Library::Listenable(3pm)

NAME
Aspect::Library::Listenable - Observer pattern with events SYNOPSIS
# The class that we will make listenable package Point; sub new { bless { color => 'blue' }, shift; } sub erase { print 'erased!'; } sub get_color { $_[0]->{color}; } sub set_color { $_[0]->{color} = $_[1]; } package main; use Aspect; use Aspect::Library::Listenable; # Setup the simplest listenable relationship: a signal # Define the aspect for the listenable relationship aspect Listenable => ( Erase => call 'Point::erase' ); # Now add a listener my $erase_listener = sub { print shift->as_string }; add_listener $point, Erase => $erase_listener; my $point = Point->new; $point->erase; # prints: "erased! name:Erase, source:Point" remove_listener $point, Erase => $erase_listener; $point->erase; # prints: "erased!" # A more complex relationship: listeners get old and new color values # and will only be notified if these values are not equal aspect Listenable => (Color => call 'Point::set_color', color => 'get_color'); add_listener $point, Color => my $color_listener = sub { print shift->as_string }; $point->set_color('red'); # prints: "name:Color, source:Point, color:red, old_color:blue, params:red" $point->set_color('red'); # does not print anything, color unchanged remove_listener $point, Color => $color_listener; # listeners can be callback, as above, or they can be objects package ColorListener; sub new { bless {}, shift } sub handle_event_Color { print "new color: ". shift->color }; package main; add_listener $point, Color => my $object_listener = ColorListener->new; $point->set_color('green'); # prints: "new color: green" remove_listener $point, Color => $object_listener; # listeners can also be specific methods on objects package EraseListener; sub new { bless {}, shift } sub my_erase_handler { print 'heard an erase event!' } package main; add_listener $point, Color => [my_erase_handler => my $method_listener = EraseListener->new] $point->erase; # prints: "heard an erase event!" remove_listener $point, Color => $method_listener; DESCRIPTION
A reusable aspect for implementing the Listenable design pattern. It lets you to define listenables and the events they fire. Then you can add/remove listeners to these listenables. When specific methods of the listenable are called, registered listeners will be notified. Some examples of use are: o A timer that allows registration of listeners. They will receive events when the timer fires. o In an MVC application, as a mechanism for registering views as listeners of models. Then when models change, views receive events, which they handle by updating the display. Several views can be set as listeners for any event of any model. The Listenable pattern is a variation of the basic Observer pattern: 1. Listeners can be attached to specific events fired by a listenable. Listenables can fire several types of events. In the basic Observer pattern, observers are attached to entire observables. 2. Listeners receive an event as their only parameter. From this event, they can get its name, source, old/new states of the listenable, and any parameters that were sent to the listenable method that fired the event. Because it is implemented using aspects, there is no change required to the listenable or listener classes. For example, you are not required to fire events after performing interesting state changes in the listenable. The aspect will do this for you. USING
Creating listenable relationships between objects is done in two steps. First you must define the relationship between the classes, then you can instantiate the defined relationship between instances of these classes. DEFINING Defining the relationships between classes is done once per program run. This is similar to how methods and classes are defined only once. Each listenable relationship between classes is defined by one aspect, answering 3 questions: 1. What is the name of the event being fired? 2. What methods on what listenable objects cause events to be fired? 3. What data will be present in the event object, so that listeners can gather information about the change to the listenable that caused the event to fire? This is optional. The event could carry no data at all, except its name and source. You create a listenable aspect so: aspect Listenable => (EVENT_NAME => POINTCUT, EVENT_DATA) The "EVENT_DATA" part is optional. The three parameters are your answers to the questions above: EVENT_NAME The string event name. A listenable can participate in several listenable aspects, each with a different event name. Another way to describe it, is that a listenable can fire several types of events. POINTCUT A pointcut object (Aspect::Pointcut) that selects "hot" methods. After these methods are run, an event will be fired. EVENT_DATA Optional hash of keys and values you want to add to the event before it is fired. They key is the string name of the property that will be given to the event, and the value is a string name of a method, on the listenable, that will be called to get the property value. The getter method on the listenable must exist for this to work. If you set "EVENT_DATA", then change checking will be performed before firing. The event will only be fired, if the event data has changed. If there is no "EVENT_DATA", the event will always be fired. The "EVENT_DATA" feature is useful for providing listeners with more information about the event. Example: when listening to a selection widget, it may by used for informing listeners of the item selected. Here is an example of transforming a selector widget, so that it will fire an event, right after it has received a click from the user. Listeners can get the selected index from the event they receive: aspect Listenable => ( ItemSelected => call 'SelectorWidget::click', selected_index => 'selected_index', ); This assumes that there exists a method "SelectorWidget::selected_index", that will return the currently selected item, and a method "click", called whenever the user clicks the widget. The event will only be fired if the "selected_index" has changed. Because the aspect should be created only Once during a program run, for each listenable relationship type, there are several options for choosing the place to actually create it: o In the listenable, outside any methods or in some static initializer o In the top level program unit o In a Facade over some framework o In a new class you create, which must be used by the code adding/removing listeners Now all that is needed is some way to add and remove listener objects, from a specific listenable, so that the event will actually be handled by someone, and not just fired into the void. ADDING AND REMOVING LISTENERS The simplest listener is a "CODE" ref. It can added and removed so: use Aspect::Library::Listenable; my $code = sub { print "event!" } add_listener $point, Color => $code; # add $point->set_color('red'); # $code will be run remove_listener $point, Color => $code; # remove $point->set_color('yellow'); # event will not fire The event object is the only parameter received by the callback. The other two types of listeners are object, and method: 1. Object - the method "handle_event_EVENT_NAME" will be called. 2. Array ref with two elements- scalar method name and listener object. When the listener is an object , the method name to be called is computed from the event name by adding "handle_event_" in front of the event name. For example: a car object will call the method "handle_event_FrontLeftDoorOpened" on its listeners that are objects. When the listener is an array ref (method listener), the method name (1st element) is called on the object (2nd element). When removing this type of listener, you do not remove the array ref but the listener object, i.e. exactly like you remove an object listener. For method listeners, you can also change the parameter list of the method. Usually, the event is the only parameter to the listener method. By changing the parameter list, you can turn any existing method into a listener method, without changing it. You change the parameter list, by providing a list of event properties, whose values will become the new parameter list. Here is how to make a "Family::set_father_name" run each time "Person::set_name" is called on the father object: aspect Listenable => ( NameChange => call 'Person::set_name', name => 'name', ); $father = Person->new; $family = Family->new; add_listener $father, NameChange => [set_father_name => $family, [qw(name)]]; $father->set_name('dan'); # $family->set_father_name('dan') will be called HANDLING EVENTS Listener code is called with one parameter: the event. Its class is "Aspect::Listenable::Event". All events have at least these properties: "name" The name of the event as defined in the aspect. "source" The listenable object. "params" The event was fired because a method was called. In this property you will find an array ref of the parameters sent to that method. Besides these properties, you can also access any properties that were defined to be in the event state, when the listenable aspect was created. For each such property, there is another, with "old_" prefixed, which holds the value of the property on the listenable, before the event was fired. You access properties on the event using getters. To get the new color of a point after a "Color" event: sub handle_event_Color { my $event = shift; print $event->color; } CAVEATS
o Only works with hash based objects. May use "Scalar-Footnote" in the future to get around this, or try to keep listeners in the aspect, not the listenable. o Supports removing listeners, but not aspects. Aspects will be removed and event will stop firing, but listeners will not be cleaned up from listenables. Setup your aspect only once per relationship type, and call "aspect Listenable..." in a void context. SEE ALSO
"Class::Listener", "Class::Observable". Both are object-oriented solutions to the same problem. Both force you to change the listenable class, by adding the code to fire events inside your "hot" methods. AUTHORS
Adam Kennedy <adamk@cpan.org> Marcel Gruenauer <marcel@cpan.org> Ran Eilam <eilara@cpan.org> COPYRIGHT
Copyright 2001 by Marcel Gruenauer Some parts copyright 2009 - 2012 Adam Kennedy. This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.14.2 2012-02-01 Aspect::Library::Listenable(3pm)
All times are GMT -4. The time now is 07:24 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy