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

 
ATF-TEST-PROGRAM(1)					    BSD General Commands Manual 				       ATF-TEST-PROGRAM(1)

NAME
atf-test-program -- common interface to ATF test programs SYNOPSIS
atf-test-program [-r resfile] [-s srcdir] [-v var1=value1 [.. -v varN=valueN]] test_case atf-test-program -l DESCRIPTION
Test programs written using the ATF libraries all share a common user interface, which is what this manual page describes. NOTE: There is no binary known as atf-test-program; what is described in this manual page is the command-line interface exposed by the atf-c, atf-c++ and atf-sh bindings. In the first synopsis form, the test program will execute the provided test case and print its results to the standard output, unless other- wise stated by the -r flag. Optionally, the test case name can be suffixed by ':cleanup', in which case the cleanup routine of the test case will be executed instead of the test case body; see atf-test-case(4). Note that the test case is executed without isolation, so it can and probably will create and modify files in the current directory. To execute test cases in a controller manner, you need a runtime engine that understands the ATF interface. The recommended runtime engine is kyua(1). You should only execute test cases by hand for debugging pur- poses. In the second synopsis form, the test program will list all available test cases alongside their meta-data properties in a format that is machine parseable. This list is processed by kyua(1) to know how to execute the test cases of a given test program. The following options are available: -l Lists available test cases alongside a brief description for each of them. -r resfile Specifies the file that will receive the test case result. If not specified, the test case prints its results to stdout. If the result of a test case needs to be parsed by another program, you must use this option to redirect the result to a file and then read the resulting file from the other program. Note: do not try to process the stdout of the test case because your program may break in the future. -s srcdir The path to the directory where the test program is located. This is needed in all cases, except when the test program is being executed from the current directory. The test program will use this path to locate any helper data files or utilities. -v var=value Sets the configuration variable var to the value value. SEE ALSO
kyua(1) BSD
March 2, 2014 BSD
All times are GMT -4. The time now is 07:17 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy