|
Shell Programming and Scripting 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. |
Tags |
jil, parsing, shell script |
![]() |
|
Thread Tools | Search this Thread | Display Modes |
#8
|
||||
|
||||
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. |
Sponsored Links | ||
|
#9
|
||||
|
||||
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 |
Sponsored Links | ||
|
#10
|
||||
|
||||
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?
|
Sponsored Links | ||
|
![]() |
Thread Tools | Search this Thread |
Display Modes | |
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
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 |
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 |
i want to extract details for particular file | bp_vardhaman | Shell Programming and Scripting | 6 | 08-21-2008 10:55 AM |
|