Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Help with printing advance output format from a file Post 302941717 by AAHinka on Monday 20th of April 2015 10:55:16 AM
Old 04-20-2015
Help with printing advance output format from a file

Hi,


below 'awk' code was given for my thread 'Help with printing output format from a file ' earlier, however script is not resulting expected output with below file content.


Code:
 
cat test_tes123.dml
 
record
  string("\001") emp_num; /* CHAR(11) NOT NULL*/
  date("YYYYMMDD") start_date = NULL; /* DATE NOT NULL*/
  date("YYYYMMDD") end_date = NULL; /* DATE NOT NULL*/
  string(1) status = NULL; /* CHAR(1) NOT NULL*/
  string(1) flag = NULL; /* CHAR(1)*/
  decimal("\001", maximum_length=12) unit_number = NULL; /* VARCHAR2(9)*/
  string("\001", maximum_length=9) Sal= NULL; /* VARCHAR2(9) NOT NULL*/
  string("\001", maximum_length=11) manager = NULL; /* VARCHAR2(11)*/
  decimal("\001", maximum_length=12) d_no  = NULL;
end;

 
-------
 
awk 'NF>1{s=s (s?";":x) $2; sub(/;$/,x,s)} END{print s}' test_tes123.dml
 
emp_num;start_date;end_date;status;flag;maximum_length=12);maximum_length=9);maximum_length=11);maximum_length=12)

 
---Where expected output is:
 
emp_num;start_date;end_date;status;flag;unit_number;Sal;manager;d_no

Could you please suggest solution for above query.

Thanks in advance,
AA HINKA
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell programming - running the exe file and printing the output.. ?

hai i have a directory lib in that lib directory i have 10 batch files. step i have to do is 1) EXECUTE ALL THE FILES by using the command dwarfdump <filename>| grep DW_AT_SUN_command_line and put the output in one text file.instead of executing the files for all the 10 files... (13 Replies)
Discussion started by: shenthil76
13 Replies

2. Shell Programming and Scripting

Dynamic output file generation using a input text file with predefined output format

Hi, I have two files , one file with data file with attributes that need to be sent to another file to generate a predefined format. Example: File.txt AP|{SSHA}VEEg42CNCghUnGhCVg== APVG3|{SSHA}XK|"password" AP3|{SSHA}XK|"This is test" .... etc --------- test.sh has... (1 Reply)
Discussion started by: hudson03051nh
1 Replies

3. Shell Programming and Scripting

Advance file parsing...

hi all i have a file of the format Time(starting from 0 in asc order) bytes service flags protocols e.g. 0, 0, 0, 56, 56 1, 524, 3, 6, 75 1, 624, 0, 43, 53 2, 72, 0, 43, 80 3, ... (1 Reply)
Discussion started by: vaibhavkorde
1 Replies

4. Shell Programming and Scripting

Printing the output of a db2 query on to an unix file

I want to print the output of a db2 query, on to an unix file in a manner that the columns are separated by 'commas'. Please help me out..thanx in advance (1 Reply)
Discussion started by: prasan_ven
1 Replies

5. Shell Programming and Scripting

Match list of strings in File A and compare with File B, C and write to a output file in CSV format

Hi Friends, I'm a great fan of this forum... it has helped me tone my skills in shell scripting. I have a challenge here, which I'm sure you guys would help me in achieving... File A has a list of job ids and I need to compare this with the File B (*.log) and File C (extend *.log) and copy... (6 Replies)
Discussion started by: asnandhakumar
6 Replies

6. Shell Programming and Scripting

Recursive file processing from a path and printing output in a file

Hi All, The script below read the path and searches for the directories/subdirectories and for the files. If files are found in the sub directories then read the content of the all files and put the content in csv(comma delimted) format and the call the write to xml function to write the std... (1 Reply)
Discussion started by: Optimus81
1 Replies

7. Shell Programming and Scripting

Script to generate Excel file or to SQL output data to Excel format/tabular format

Hi , i am generating some data by firing sql query with connecting to the database by my solaris box. The below one should be the header line of my excel ,here its coming in separate row. TO_CHAR(C. CURR_EMP_NO ---------- --------------- LST_NM... (6 Replies)
Discussion started by: dani1234
6 Replies

8. UNIX for Dummies Questions & Answers

Help with printing output format from a file

Hi, I need help in printing data in below format from file extensions with .dml, i have listed details below file name is test_temp.dml, location in /home/users/test01/test_temp.dml file content: sample_type= record decimal(",") test_type; date("DD-MM-YYYY")(",") test_date... (2 Replies)
Discussion started by: AAHinka
2 Replies

9. Shell Programming and Scripting

Printing Terminal Output to a Error File

I am having a bash script which is basically invoking a python program to validate the Source Query results against the target query results. I am placing all the queries in a .sql file. I want to write to a Error log file incase if the syntax is wrong or if the column is not present in the... (4 Replies)
Discussion started by: ronitreddy
4 Replies

10. UNIX for Beginners Questions & Answers

Printing df -h output in json format

Hi All, i am trying to print the df -h ouput in json format. using below script. #!/usr/bin/env bash df -h > /tmp/sdf nawk '{print " "$1" "$2" "$3" "$4" "$5" "$6" "}' /tmp/sdf > /tmp/sdf1 nawk 'NR==1 { for (i=1; i<=NF; i++) { f = i }}{ print $(f), $(f), $(f), $(f), ... (2 Replies)
Discussion started by: sravani25
2 Replies
XENTRACE_FORMAT(1)					      General Commands Manual						XENTRACE_FORMAT(1)

NAME
xentrace_format - pretty-print Xen trace data SYNOPSIS
xentrace_format [ DEFS-FILE ] DESCRIPTION
xentrace_format parses trace data in xentrace binary format from standard input and reformats it according to the rules in a file of defi- nitions (DEFS-FILE), printing to standard output. The rules in DEFS-FILE should have the format shown below: event_id whitespace format Each rule should start on a new line. The format string may include format specifiers, such as: %(cpu)d, %(tsc)d, %(event)d, %(1)d, %(2)d, %(3)d, %(4)d, %(5)d [ the `d' format specifier output in decimal, alternatively `x' will output in hexadecimal and `o' will output in octal ] These correspond to the CPU number, event ID, timestamp counter and the 5 data fields from the trace record. There should be one such rule for each type of event to be pretty-printed (events which do not have formatting rules are ignored). A sample format file for Xen's predefined trace events is available in the file tools/xentrace/formats in the Xen source tree. Depending on your system and the rate at which trace data is produced, this script may not be able to keep up with the output of xentrace if it is piped directly. In these circumstances you should have xentrace output to a file for processing off-line. AUTHOR
Mark A. Williamson <mark.a.williamson@intel.com> SEE ALSO
xentrace(8), xentrace_cpusplit(1) Xen domain 0 utils 11 May 2004 XENTRACE_FORMAT(1)
All times are GMT -4. The time now is 07:38 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy