LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 01-08-2006, 03:42 AM   #1
abdul_zu
Member
 
Registered: Feb 2005
Posts: 71

Rep: Reputation: 15
Perl question


Hi all,

I have one log file i want to take only one world from each line. here is my log file format:

Code:
/SIP/Registry/110001                              : 192.xxx.xxx.1:5060:1200:110001:sip:110001@xxx.xxx.xxx.229:5060;line=4b8886e9dac5a8ce
/SIP/Registry/110005                              : xxx.168.xxx.6:16700:120::sip:192.168.xxx.6:16700
/SIP/Registry/111129                              : xxx.68.xxx.6:1220:300:111129:sip:111129@xxx.68.xxx.6:1220
/SIP/Registry/111130                              : xxx.86.xxx.xxx:1220:10:111130:sip:111130@xxx.86.123.xxx:1220
I want to take only these numbers 110001 from /SIP/Registry/110001?

I will be appricate if any one can help.
 
Old 01-08-2006, 04:29 AM   #2
barrett9h
LQ Newbie
 
Registered: Jun 2004
Location: Rio / Brazil
Distribution: Slackware
Posts: 11

Rep: Reputation: 0
Code:
sed 's/^[^0-9]*\([0-9]*\).*$/\1/'
or
Code:
cut -d / -f 4 | cut -d ' ' -f 1
I'm sure there are many other ways.
 
Old 01-08-2006, 04:34 AM   #3
abdul_zu
Member
 
Registered: Feb 2005
Posts: 71

Original Poster
Rep: Reputation: 15
Hi,

I used the following split fuction and got working well.

Code:
open (ACTLOG, "/var/log/asterisk/endpoints.log");
  while ($record = <ACTLOG>) {

    @personal = split(/ +/, $record);
    @myarray = split(/\//,$personal[0]);
       $update_ep->execute(1,$myarray[3]);
  }
 
Old 01-08-2006, 08:08 AM   #4
trickykid
LQ Guru
 
Registered: Jan 2001
Posts: 24,149

Rep: Reputation: 269Reputation: 269Reputation: 269
Moved: More suitable in our Programming forum.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
a perl question thanhVic Programming 1 03-13-2005 02:45 AM
Hiding code in PERL, perl gui question randomx Programming 1 06-26-2004 03:22 PM
perl question eph Programming 4 04-04-2004 09:51 PM
perl(Cwd) perl(File::Basename) perl(File::Copy) perl(strict)....What are those? Baldorg Linux - Software 1 11-09-2003 08:09 PM
Perl question isajera Programming 2 07-23-2001 02:29 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 01:11 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration