Hi Jean,
i used your code in my script which was also told by you : but the files are not matching the patterns and not getting printed
ls -l 2>/dev/null |
awk -v var=$TOTAL -v var2=$job_date '
BEGIN { pattern = "Name\\." var "\\.Version\\.[0-9]+\\.xml$" }
$0 ~ pattern {
sub(/\.[^.]*$/, "", $NF); # Removes extension
FileCount++;
FileName[FileCount] = $NF;
FileSize[FileCount] = $5;
}
END {
print "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
print "<AuditFile Version=\"2.0\">";
print "<Header>";
printf "<BusinessDate>%s</BusinessDate>\n",var2
print "<SubmissionSequenceNr>1</SubmissionSequenceNr>"
print "<SubmissionVersionNr>4</SubmissionVersionNr>"
print "<AdHoc>N</AdHoc>"
print "</Header>"
printf "<UnitOfWork UnitSequenceNr=\"1\" FileCount=\"%d\" ArchiveID=\"106B\">\n",var
for (f=1; f<=FileCount; f++) {
print "<DataFile>";
printf "<FileName>%s</FileName>\n", FileName[f];
printf "<FileSize>%d</FileSize>\n", FileSize[f];
print "</DataFile>";
}
}
'
---------- Post updated at 11:44 AM ---------- Previous update was at 11:43 AM ----------
Quote:
Originally Posted by
abhinav192
Hi Jean,
i used your code in my script which was also told by you : but the files are not matching the patterns and not getting printed
ls -l 2>/dev/null |
awk -v var=$TOTAL -v var2=$job_date '
BEGIN { pattern = "Name\\." var "\\.Version\\.[0-9]+\\.xml$" }
$0 ~ pattern {
sub(/\.[^.]*$/, "", $NF); # Removes extension
FileCount++;
FileName[FileCount] = $NF;
FileSize[FileCount] = $5;
}
END {
print "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
print "<AuditFile Version=\"2.0\">";
print "<Header>";
printf "<BusinessDate>%s</BusinessDate>\n",var2
print "<SubmissionSequenceNr>1</SubmissionSequenceNr>"
print "<SubmissionVersionNr>4</SubmissionVersionNr>"
print "<AdHoc>N</AdHoc>"
print "</Header>"
printf "<UnitOfWork UnitSequenceNr=\"1\" FileCount=\"%d\" ArchiveID=\"106B\">\n",var
for (f=1; f<=FileCount; f++) {
print "<DataFile>";
printf "<FileName>%s</FileName>\n", FileName[f];
printf "<FileSize>%d</FileSize>\n", FileSize[f];
print "</DataFile>";
}
}
'
---------- Post updated at 11:44 AM ---------- Previous update was at 11:44 AM ----------
Quote:
Originally Posted by
abhinav192
Hi Jean,
i used your code in my script which was also told by you : but the files are not matching the patterns and not getting printed
ls -l 2>/dev/null |
awk -v var=$TOTAL -v var2=$job_date '
BEGIN { pattern = "Name\\." var "\\.Version\\.[0-9]+\\.xml$" }
$0 ~ pattern {
sub(/\.[^.]*$/, "", $NF); # Removes extension
FileCount++;
FileName[FileCount] = $NF;
FileSize[FileCount] = $5;
}
END {
print "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
print "<AuditFile Version=\"2.0\">";
print "<Header>";
printf "<BusinessDate>%s</BusinessDate>\n",var2
print "<SubmissionSequenceNr>1</SubmissionSequenceNr>"
print "<SubmissionVersionNr>4</SubmissionVersionNr>"
print "<AdHoc>N</AdHoc>"
print "</Header>"
printf "<UnitOfWork UnitSequenceNr=\"1\" FileCount=\"%d\" ArchiveID=\"106B\">\n",var
for (f=1; f<=FileCount; f++) {
print "<DataFile>";
printf "<FileName>%s</FileName>\n", FileName[f];
printf "<FileSize>%d</FileSize>\n", FileSize[f];
print "</DataFile>";
}
}
'