Hi,
I have a file which contains the data in the below format and need to develop a script which will give the output in the tabular format.
Could you please advice me.
Folder:
Workflow: [wf_ABC] version [1].
Workflow run status: [Scheduled]
Workflow run error code: [0]
Schedule time: [Wed May 12 00:05:00 2010]
Workflow run type: [Schedule]
Run workflow as user: [John]
Integration Service: [Inte_Ser]
Folder: [Test]
Workflow: [Wf_Xyz] version [1].
Workflow run status: [Scheduled]
Workflow run error code: [0]
Schedule time: [Wed May 12 00:05:00 2010]
Workflow run type: [Schedule]
Run workflow as user: [Administrator]
Integration Service: [Inte_Ser]
---
---
---
Output : -
Folder Name Workflow Name Scheduled Time
======================================================
Tutorial wf_ABC 12-May-2010 00:05:00
Test Wf_Xyz 12-May-2010 00:05:00
$
$
$ cat f1
Folder:
Workflow: [wf_ABC] version [1].
Workflow run status: [Scheduled]
Workflow run error code: [0]
Schedule time: [Wed May 12 00:05:00 2010]
Workflow run type: [Schedule]
Run workflow as user: [John]
Integration Service: [Inte_Ser]
Folder: [Test]
Workflow: [Wf_Xyz] version [1].
Workflow run status: [Scheduled]
Workflow run error code: [0]
Schedule time: [Wed May 12 00:05:00 2010]
Workflow run type: [Schedule]
Run workflow as user: [Administrator]
Integration Service: [Inte_Ser]
$
$
$ ##
$ perl -ne 'BEGIN {printf("%-20s %-20s %-s\n", "Folder Name", "Workflow Name", "Scheduled Time");
> printf("%s %s %s\n", "="x20, "="x20, "="x24)}
> if (/^Folder: \[(.*?)\]/) {printf("%-20s ",$1)}
> elsif (/^Workflow: \[(.*?)\]/) {printf("%-20s ",$1)}
> elsif (/^Schedule time: \[(.*?)\]/) {printf("%-s\n",$1)}
> ' f1
Folder Name Workflow Name Scheduled Time
==================== ==================== ========================
Tutorial wf_ABC Wed May 12 00:05:00 2010
Test Wf_Xyz Wed May 12 00:05:00 2010
$
$
tyler_durden
data.dat is the inputfile.
$ cat createtable.sh
#!/bin/sh
echo "Folder Name Workflow Name Scheduled Time"
echo "==================== ==================== ========================"
<data.dat grep -E 'Folder:|Workflow:|Schedule time:' | sed -n 'N;N;s/\n/ /gp' |\
sed 's/Folder: \[//;s/\] Workflow: \[/,/;s/\].*: \[/,/;s/]$//' |
while read line
do
a=$(echo $line | sed 's/,.*//')
b=$(echo $line | sed 's/.*,\(.*\),.*/\1/')
c=$(echo $line | sed 's/.*,//')
printf "%-21s %-21s %-25s\n" "$a" "$b" "$c"
done
$ ./createtable.sh
Folder Name Workflow Name Scheduled Time
==================== ==================== ========================
Tutorial wf_ABC Wed May 12 00:05:00 2010
Test Wf_Xyz Wed May 12 00:05:00 2010
$