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
IP2HOSTNAME(1)						      General Commands Manual						    IP2HOSTNAME(1)

NAME
ip2hostname - converts IP addresses to their respective hostnames SYNOPSIS
ip2hostname [-h] [ -p printf_format ] [ [-i extension] file [...] ] DESCRIPTION
-h help (shows this usage information) (mnemonic: 'h'elp) -p printf_format use this printf format for IP address and hostname, respectively. The default format is '%.0s%s', which supresses the printing of the IP address (i.e. "%.0s" specifies printing a string with a maximum width of zero). To maintain column widths (since both the IP address and hostname vary in lenght), a format like this may be useful: '%-16.16s %-20s' (mnemonic: 'p'rintf format) -i extension edit the files in place (rather than sending to standard output) This option requires file name(s) argument(s). The extension is added to the name of the old file to make a backup copy. If you don't wish to make a backup, use "-I". (mnemonic: edit 'i'n place) -I like "-i" but no backup is made. (mnemonic: edit 'I'n place, trusting this script 'I'mplicitly. ;^) SEE ALSO
add_ds.pl(1), add_txrx(1), event2vrule(1), flowscan(1), locker(1) AUTHOR
This manual page was written by Anibal Monsalve Salazar, for the Debian Project. IP2HOSTNAME(1)
All times are GMT -4. The time now is 03:56 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy