Perl script to filter the string


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Perl script to filter the string
# 1  
Old 07-16-2013
Perl script to filter the string

Hi folks,

I have a log file with the lines in the below format.

Code:
Jul  1 23:00:51 10.212.3.251 SS: %SYS-7-CLI_SCHEDULE:  some error occured

I want to split the line based on the " %SYS-7-CLI_SCHEDULE: " value.
The criteria is the should store the word that starts with % i.e., %SYS-7-CLI_SCHEDULE:

now

$left should contain Jul 1 23:00:51 10.212.3.251 SS:
$matched should contain %SYS-7-CLI_SCHEDULE:
$right should contain some error

Could anyone please help with the perl script with regular expression to get out of this.

Thanks in advance ....


Regards,
J
# 2  
Old 07-16-2013
Look for $&, $` and $' in perlvar - perldoc.perl.org
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Need to filter string between specific string in ksh

My argument has data as below. 10.9.9.85 -rwxr-xr-x user1 2019-10-15 17:40 /app/scripts/testingscr5.scr 127869538 -rwxr-xr-x user1 2019-10-15 17:40 /app/scripts/testingscr56scr 127869538 ....... (note all these between lines will start with hyphen '-' ) -rwxr-xr-x user1 2019-10-15 17:40... (3 Replies)
Discussion started by: mohtashims
3 Replies

2. Shell Programming and Scripting

Shell Script (ksh) - SQLPlus query filter using a string variable

Using ksh, I am using SQLPlus to execute a query with a filter using a string variable. REPO_DB=DEV1 FOLDER_NM='U_nmalencia' FOLDER_CHECK=$(sqlplus -s /nolog <<EOF CONNECT user/pswd_select@${REPO_DB} set echo off heading off feedback off select subj_name from subject where... (5 Replies)
Discussion started by: nkm0brm
5 Replies

3. UNIX for Dummies Questions & Answers

Filter a particular string

Hi, I have a long log file. Out of which I want to filter particular occurrences where APC=4-033-0. Please help how it can be done. Input : +++ ELEMENT 12-05-27 23:15:06 CC 3482 #040185 > REPT APB TPE=C7NTL SM=22 OPC=4-003-7 APC=4-033-4 inaccessible END OF REPORT #040185 ++- ... (7 Replies)
Discussion started by: vanand420
7 Replies

4. Shell Programming and Scripting

Perl script - Help me extracting a string

I have input like this : TNS Ping Utility for Linux: Version 11.2.0.1.0 - Production on 07-FEB-2012 04:19:45 Copyright (c) 1997, 2009, Oracle. All rights reserved. Used parameter files: /t3local_apps/apps/oracle/product/11.2.0/network/admin/sqlnet.ora Used TNSNAMES adapter to resolve... (3 Replies)
Discussion started by: dnam9917
3 Replies

5. Shell Programming and Scripting

Displaying exponent value as string in PERL script

Hello All, I am currently having an issue displaying a exponent value using perl, I have a perl program which generates an xls file. This xls is populated with values from a database. But for a certain column which I have made explicitely text and also implemented keep_leading_zeroes()... (3 Replies)
Discussion started by: sbasetty
3 Replies

6. Shell Programming and Scripting

Sed filter words from string

I have following string in a variable: str="sstring garbage adfsdf tab.col1 lkad rjfj tab2.col2 adja tab2.col4 garbage" I want to filter "word.word" pattern from it. I assume the pattern won't occur in start or end of the string. Output shoud be: tab.col1 tab2.col2 tab2.col4 Can this be... (7 Replies)
Discussion started by: amicon007
7 Replies

7. Shell Programming and Scripting

filter the string from a file ??

I have a file in which there are strings given below: inode 1138932c(mqsiadm) inode 1257904c(mqsiadm) I want to get the nos. only form these. The o/p should be 1138932 1257904 How to filter this out ?? (11 Replies)
Discussion started by: varungupta
11 Replies

8. Shell Programming and Scripting

String replace perl script error

I have written down a simple perl program to replace a string from a word file. My script does'nt seem to work. Any pointers to make it work will be appreciated. The code is given below. #!/usr/bin/perl while (<>) { open(FILE,$_); while (<FILE>) { s/This/I did it/g; }... (6 Replies)
Discussion started by: MobileUser
6 Replies

9. Shell Programming and Scripting

perl script to filter logfile

i was wondering if anyone can help me, how could i write in perl a a script that would look through a log file and print onscreen the contents of the log file excluding lines that contain '192.168.1.' and entries that contain directory paths that arent in the directory /usr/local/httpd/htdocs/ i... (4 Replies)
Discussion started by: norsk hedensk
4 Replies
Login or Register to Ask a Question