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

 
NETIO230A-CLI(1)					      General Commands Manual						  NETIO230A-CLI(1)

NAME
netio230a-cli - CLI to python-netio230a SYNOPSIS
netio230a-cli [--host HOST] [--port PORT] [--username USERNAME] [--password PASSWORD] -s SOCKET [--on] DESCRIPTION
netio230a-cli is a command line interface to access the Koukaam NETIO-230A, a cheap but advanced multiple socket with Ethernet control. Options: -? show help message and exit -h HOST, --host=HOST Hostname for the device (defaults to the first one found by the discovery in your LAN) -p PORT, --port=PORT TCP port (defaults to 1234) -u USERNAME, --username=USERNAME username to use for login (defaults to admin) -w PASSWORD, --password=PASSWORD password to use for login (will ask if left empty) -s SOCKET#, --socket=SOCKET# socketnumber (1-4) to switch on/off --on switch on when --on set, off if omitted AUTHOR
netio230a-cli was written by Philipp Klaus <philipp.l.klaus@web.de>. This manual page was written by Philipp Huebner <debalance@debian.org>, for the Debian project (and may be used by others). SEE ALSO
netio230a-discover(1), netio230a-gui(1) netio230a-cli 2010-03-09 NETIO230A-CLI(1)
All times are GMT -4. The time now is 02:19 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy