Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Help with awk using * (asterisk) as the delimiter Post 302759713 by newbie_01 on Tuesday 22nd of January 2013 09:06:33 PM
Old 01-22-2013
Help with awk using * (asterisk) as the delimiter

Hi

I am trying to parse the following lines and has to use * (asterisk) as the delimiter.

These lines are in a file, for example tmp.txt and I am using a while loop


Code:
 
 
tmp.txt:
 
14-OCT-2012 06:38:59 * (CONNECT_DATA=(SID=test)(GLOBAL_NAME=test.mydb.com.ch)(CID=(PROGRAM=Z:\Ora6i\BIN\ifrun60.EXE)(HOST=8000XXX05004RV)(USER=mickey
))) * (ADDRESS=(PROTOCOL=tcp)(HOST=11.90.24.239)(PORT=1552)) * establish * test * 0
14-OCT-2012 06:39:15 * (CONNECT_DATA=(SID=test)(GLOBAL_NAME=test.mydb.com.ch)(CID=(PROGRAM=Z:\Ora6i\BIN\RWRBE60.exe)(HOST=8000XXX05004RV)(USER=mickey
))) * (ADDRESS=(PROTOCOL=tcp)(HOST=11.90.24.239)(PORT=1574)) * establish * test * 0
14-OCT-2012 06:40:48 * (CONNECT_DATA=(SID=test)(GLOBAL_NAME=test.mydb.com.ch)(CID=(PROGRAM=Z:\Ora6i\BIN\ifrun60.EXE)(HOST=8200XXX138060Z)(USER=mouse))) * (ADDRESS=(PROTOCOL=tcp)(HOST=11.217.35.94)(PORT=2525)) * establish * test * 0
14-OCT-2012 07:01:04 * (CONNECT_DATA=(CID=(PROGRAM=)(HOST=server911)(USER=oracle))(COMMAND=status)(ARGUMENTS=64)(SERVICE=test)(VERSION=135296000)) *
status * 0
 
- while loop code block
 
   while read line
   do
      echo " ---> Parsing ---> "
      echo " - $line"
      echo ""
      timestamp=`echo $line | awk -F* '{ print $1 }'`
      echo " - timestamp = ${timestamp}"
      echo ""
      echo ""
   done < ${pid}.tmp.01

Instead of just getting the timestamp, I am getting the timestamp plus what looks like a directory listing of all files, i.e. like a timestamp and echo * of the directory that I am in.

Can anyone please advise how to get around this?

Feeback/advise much appreciated. Thanks in advance.

---------- Post updated at 09:06 PM ---------- Previous update was at 08:42 PM ----------

Note that the strings are supposed to be one long line of strings so tmp.txt should be as below:

Code:
 
14-OCT-2012 06:38:59 * (CONNECT_DATA=(SID=test)(GLOBAL_NAME=test.mydb.com.ch)(CID=(PROGRAM=Z:\Ora6i\BIN\ifrun60.EXE)(HOST=8000XXX05004RV)(USER=mickey))) * (ADDRESS=(PROTOCOL=tcp)(HOST=11.90.24.239)(PORT=1552)) * establish * test * 0
14-OCT-2012 06:39:15 * (CONNECT_DATA=(SID=test)(GLOBAL_NAME=test.mydb.com.ch)(CID=(PROGRAM=Z:\Ora6i\BIN\RWRBE60.exe)(HOST=8000XXX05004RV)(USER=mickey))) * (ADDRESS=(PROTOCOL=tcp)(HOST=11.90.24.239)(PORT=1574)) * establish * test * 0
14-OCT-2012 06:40:48 * (CONNECT_DATA=(SID=test)(GLOBAL_NAME=test.mydb.com.ch)(CID=(PROGRAM=Z:\Ora6i\BIN\ifrun60.EXE)(HOST=8200XXX138060Z)(USER=mouse))) * (ADDRESS=(PROTOCOL=tcp)(HOST=11.217.35.94)(PORT=2525)) * establish * test * 0
14-OCT-2012 07:01:04 * (CONNECT_DATA=(CID=(PROGRAM=)(HOST=server911)(USER=oracle))(COMMAND=status)(ARGUMENTS=64)(SERVICE=test)(VERSION=135296000)) * status * 0

 
Net::Time(3pm)						 Perl Programmers Reference Guide					    Net::Time(3pm)

NAME
Net::Time - time and daytime network client interface SYNOPSIS
use Net::Time qw(inet_time inet_daytime); print inet_time(); # use default host from Net::Config print inet_time('localhost'); print inet_time('localhost', 'tcp'); print inet_daytime(); # use default host from Net::Config print inet_daytime('localhost'); print inet_daytime('localhost', 'tcp'); DESCRIPTION
"Net::Time" provides subroutines that obtain the time on a remote machine. inet_time ( [HOST [, PROTOCOL [, TIMEOUT]]]) Obtain the time on "HOST", or some default host if "HOST" is not given or not defined, using the protocol as defined in RFC868. The optional argument "PROTOCOL" should define the protocol to use, either "tcp" or "udp". The result will be a time value in the same units as returned by time() or undef upon failure. inet_daytime ( [HOST [, PROTOCOL [, TIMEOUT]]]) Obtain the time on "HOST", or some default host if "HOST" is not given or not defined, using the protocol as defined in RFC867. The optional argument "PROTOCOL" should define the protocol to use, either "tcp" or "udp". The result will be an ASCII string or undef upon failure. AUTHOR
Graham Barr <gbarr@pobox.com> COPYRIGHT
Copyright (c) 1995-1998 Graham Barr. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. $Id: //depot/libnet/Net/Time.pm#9 $ perl v5.8.0 2002-06-01 Net::Time(3pm)
All times are GMT -4. The time now is 06:18 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy