JSKOBS
1
My input file(inputfile.txt):
Job name.... EXTDPL_1
Created on.. 2018-11-19 14:00:00
Modified on. 2018-11-22 11:54:46
Job name.... EXTDPL_2
Created on.. 2018-11-21 12:31:27
Modified on. 2018-11-21 12:35:28
2 records listed.
>Q
expected output:
Job name Created on Modified on
EXTDPL_1 2018-11-19 14:00:00 2018-11-22 11:54:46
EXTDPL_2 2018-11-21 12:31:27 2018-11-21 12:35:28
my script:
awk '/^Job name|^Created on|^Modified on/ {print $3,$4}' inputfile.txt | awk 'ORS=NR%3?FS:RS' | awk '{printf "%-40s%-11s%-12s%-11s%-12s\n",$1,$2,$3,$4,$5}'
would like to know above three awks can be clubbed into one ?
RudiC
2
How aboutawk '
awk '
NR == 1 {printf "%-40s%-23s%-23s\n", "Job name", "Created on", "Modified on"
}
/^Job name/ {printf "%-40s", $3
}
/^Created on/ {printf "%-11s%-12s", $3,$4
}
/^Modified on/ {printf "%-11s%-12s\n", $3,$4
}
' file
Job name Created on Modified on
EXTDPL_1 2018-11-19 14:00:00 2018-11-22 11:54:46
EXTDPL_2 2018-11-21 12:31:27 2018-11-21 12:35:28
1 Like
JSKOBS
3
Hi Rudic, thanks for reply. one question.
how to stop printing header if there are no 'Job name/Created on/Modified on' match..
RudiC
4
Move that line to the first real printout, adding a condition.