Home Man
Search
Today's Posts
Register

BSD, Linux, and UNIX shell scripting — Post awk, bash, csh, ksh, perl, php, python, sed, sh, shell scripts, and other shell scripting languages questions here.

Need to extract jil file details in a excelsheet

Tags
jil, parsing, shell script, shell scripts

Login to Reply

 
Thread Tools Search this Thread
# 8  
Old 03-02-2017
Try
Code:
awk -F: '
NR==1           {HD = "insert_job,machine,date_conditions,days_of_week,start_time,timezone,description,command,alarm_if_fail"
                 for (HDCnt=i=split(HD, HDArr, OFS); i>0; i--) SRCH[HDArr[i]] 
                 print HD
                }

function PRT()  {for (i=1; i<=HDCnt; i++)       {printf "%s%s", RES[HDArr[i]], i<HDCnt?OFS:ORS
                                                }
                 split ("", RES)
                }

/--- JOB/       {if (PR) PRT()
                 PR=1
                }

                {sub ("^  *", _)
                }

$1 in SRCH      {T = $1
                 sub ($1 FS " *", "")
                 sub (/[	 ][	 ]+.*$/, "")
                 RES[T] = $0
                }

END             {PRT()
                }
' OFS=","  file

Please be aware that the structure of the line containing insert_job differs from the data in post#1 (<TAB> separated, not spaces), so the splitting off of the job_type doesn't work any more.
# 9  
Old 03-03-2017
Hi Rudi, would it be possible for you to explain how this script works? Im still learning awk and theres a lot i dont understand in this script?
Many thanks
# 10  
Old 03-03-2017
That proposal is only a slight adaption of the script you posted as your attempt. How about you try to explain it here, and we jump in on the gaps that you can't cover?
Login to Reply

« Previous Thread | Next Thread »
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Retrieving details from a tag of xml file rahulsk UNIX for Dummies Questions & Answers 1 02-16-2016 06:24 AM
Extract sentence and its details from a text file based on another file of sentences my_Perl Shell Programming and Scripting 7 10-18-2015 05:38 PM
Perl : corrupted excelsheet while trying to open scriptscript Shell Programming and Scripting 1 04-01-2013 10:28 AM
Details within file Chor419 Shell Programming and Scripting 6 08-06-2012 08:49 AM
at -l doesnt give details of the scheduled job. How to get the details? superparticle UNIX for Dummies Questions & Answers 2 11-09-2011 07:51 AM
Extract details from XML file ckchelladurai Shell Programming and Scripting 6 07-29-2011 09:01 AM
Contents and details extract problem asking... patrick87 Shell Programming and Scripting 11 03-31-2010 09:19 PM
Help with excelsheet generation Amit.Sagpariya Shell Programming and Scripting 4 03-04-2009 09:17 AM
Script for parsing details in a log file to a seperate file pingnagan UNIX for Dummies Questions & Answers 2 11-13-2008 11:21 AM
i want to extract details for particular file bp_vardhaman Shell Programming and Scripting 6 08-21-2008 10:55 AM


All times are GMT -4. The time now is 05:56 AM.

Unix & Linux Forums Content Copyright©1993-2018. All Rights Reserved.
UNIX.COM Login
Username:
Password:  
Show Password