Sponsored Content
Top Forums UNIX for Beginners Questions & Answers Generation of Regex for Perl script Post 303036003 by anbu23 on Wednesday 12th of June 2019 07:48:04 AM
Old 06-12-2019
Code:
$ echo '[string 1 ] apple [ string 2]' | perl -pi -e ' s/[[][^]]*]//g; '
 apple


Last edited by anbu23; 06-12-2019 at 09:08 AM..
This User Gave Thanks to anbu23 For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Converting perl regex to sed regex

I am having trouble parsing rpm filenames in a shell script.. I found a snippet of perl code that will perform the task but I really don't have time to rewrite the entire script in perl. I cannot for the life of me convert this code into something sed-friendly: if ($rpm =~ /(*)-(*)-(*)\.(.*)/)... (1 Reply)
Discussion started by: suntzu
1 Replies

2. Shell Programming and Scripting

shell or perl script using grep and regex

Hi, I have file stored in a directory containing information about subnet mask and next hop address in the following format 10.1.1.0/16, 255.255.0.0, 10.1.1.1 10.1.2.0/16, 255.255.0.0,10.1.2.1 here 10.1.1.0/16 represent range of ip address 10.1.1.1-10.1.1.16 given say an IP address... (1 Reply)
Discussion started by: termeric
1 Replies

3. Shell Programming and Scripting

Table / Boxes Generation in PERL

Hi all, I was wondering, if there is any way to generate boxes/tables using perl to represent some data in better format. input : Name SAlary pranav 10000 ajay 5000 shri 15000 output : _________________________ |Name |Salary |... (3 Replies)
Discussion started by: PranavEcstasy
3 Replies

4. Programming

Perl regex

HI, I'm new to perl and need simple regex for reading a file using my perl script. The text file reads as - filename=/pot/uio/current/myremificates.txt certificates=/pot/uio/current/userdir/conf/user/gamma/settings/security/... (3 Replies)
Discussion started by: jhamaks
3 Replies

5. Shell Programming and Scripting

Report generation using perl script

Hi, I have a perl script to read the log file and create a report from it. I have the script file and log file in a different directories. Now i have pipe the log file data to the perl script to create the report (HMTL file). I am using the below command this isn't working tail -f... (4 Replies)
Discussion started by: vel4ever
4 Replies

6. Programming

Perl regex

Hello, I'm trying to get a quick help on regex since i'm not a regular programmer. Below is the line i'm trying to apply my regex to..i want to use the regex in a for loop and this line will keep on changing. subject=... (4 Replies)
Discussion started by: jhamaks
4 Replies

7. Programming

Perl regex

Hello folks, Looking for a quick help on regex in my perl script. here's the string i want to parse and get the 2nd field out of it. $str = " 2013-08-07 12:29 Beta ACTIVE"; I want to extract 'Beta' out of this string. This string will keep on changing... (2 Replies)
Discussion started by: jhamaks
2 Replies

8. Shell Programming and Scripting

?= in perl regex

Could anyone please make me understand how the ?= works below .. After executing this I am getting the same output. $string="I love chocolate."; $string =~ s/chocolate(?= ice)/vanilla/; print "$string\n"; (2 Replies)
Discussion started by: scriptscript
2 Replies

9. Shell Programming and Scripting

Perl, RegEx - Help me to understand the regex!

I am not a big expert in regex and have just little understanding of that language. Could you help me to understand the regular Perl expression: ^(?!if\b|else\b|while\b|)(?:+?\s+){1,6}(+\s*)\(*\) *?(?:^*;?+){0,10}\{ ------ This is regex to select functions from a C/C++ source and defined in... (2 Replies)
Discussion started by: alex_5161
2 Replies

10. UNIX for Beginners Questions & Answers

Help with understanding this regex in a Perl script parsing a 'complex' string

Hi, I need some guidance with understanding this Perl script below. I am not the author of the script and the author has not leave any documentation. I supposed it is meant to be 'easy' if you're a Perl or regex guru. I am having problem understanding what regex to use :confused: The script does... (3 Replies)
Discussion started by: newbie_01
3 Replies
xpc_events(3)						   BSD Library Functions Manual 					     xpc_events(3)

NAME
xpc_events -- launch-on-demand for high-level events SYNOPSIS
#include <xpc/xpc.h> void xpc_set_event_stream_handler(const char *name, dispatch_queue_t targetq, xpc_handler_t handler); DESCRIPTION
XPC provides a mechanism by which launchd jobs may launch on-demand for certain higher-level events, such as IOKit events or BSD Notifica- tions. These events are delivered to the job through a handler that is set early in its execution. The period between when the event is delivered to the job and when a handler is set is race-free, and any pending events will be queued up for consumption by the job. An event is consumed when it is delivered to the handler. EVENT STREAMS
Providers of events are known as streams. Two example event streams are the IOKit stream and the BSD Notifications stream. Streams are denoted by a reverse-DNS naming scheme. For the aforementioned examples, the stream names are "com.apple.iokit.matching" and "com.apple.noti- fyd.matching", respectively. These are currently the only two supported event streams. EVENT NAMES
A launchd job may be interested in multiple events from different event streams. Each of these events has a name provided by the job in the launchd.plist(5). The occurrence of any of these events will launch the job on-demand if it is not already running. PLIST SCHEMA
Events are specified through the launchd.plist(5) with the LaunchEvents key. The value for this key is a dictionary. Each value of this dic- tionary is itself a dictionary corresponding to an event stream. The values of this inner dictionary are events that may cause the job to be launched on-demand. <key>LaunchEvents</key> <dict> <key>com.apple.iokit.matching</key> <dict> <key>com.apple.device-attach</key> <dict> <key>idProduct</key> <integer>2794</integer> <key>idVendor</key> <integer>725</integer> <key>IOProviderClass</key> <string>IOUSBDevice</string> <key>IOMatchLaunchStream</key> <true/> </dict> </dict> <key>com.apple.notifyd.matching</key> <dict> <key>com.apple.interesting-notification</key> <dict> <key>Notification</key> <string>com.apple.interesting-notification</string> </dict> </dict> </dict> The above specifies that the job will be launched when a node matching the given matching dictionary appears in the IORegistry or when a notification named "com.apple.interesting-notification" is posted using notify_post(3). NOTE: The IOMatchLaunchStream key is required to be present and be a Boolean set to true for use with XPC Events. It will be filtered out of the rest of the dictionary when given to IOKit to match. The reasons for this are historical and not applicable to other event streams. Each event stream has a different plist schema. EVENT CONSUMPTION
Events are consumed with the xpc_set_event_stream_handler() API. The stream argument specifies from which event stream the given handler will receive events. The targetq parameter specifies on which queue the handler will be synchronized. The handler will only ever receive dictio- naries. Each dictionary is guaranteed to have the XPC_EVENT_KEY_NAME key set. The value for this key is the string that was given as the name for the event in the launchd.plist(5). So if the IOKit event in the above example was received, the value of this key would be "com.apple.device-attach". In addition to the standard payload, events from the IOKit stream also have the "IOMatchLaunchServiceID" key set to a uint64_t which speci- fies the unique IORegistry ID of the node which matched the given dictionary as obtained by IORegistryEntryGetRegistryEntryID(). This value may be given to IORegistryEntryIDMatching() to obtain the registry entry which caused the event to fire. BSD Notfication events have no additional payload. xpc_set_event_stream_handler("com.apple.iokit.matching", q, ^(xpc_object_t event) { const char *name = xpc_dictionary_get_string(event, XPC_EVENT_KEY_NAME); uint64_t id = xpc_dictionary_get_uint64(event, "IOMatchLaunchServiceID"); CFMutableDictionaryRef matching = IORegistryEntryIDMatching(id); // Pass to IOServiceGetMatchingServices() or IOServiceAddNotification(). }); IMPORTANT: xpc_set_event_stream_handler() is NOT shareable. Two different subsystems in a process cannot safely both register for events from the same event stream. Therefore, libraries and frameworks should NEVER call this API. SEE ALSO
xpc_object(3), xpc_dictionary_create(3), xpc_array_create(3), notify(3) Darwin 1 July, 2011 Darwin
All times are GMT -4. The time now is 01:20 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy