My question is a continuation of
How to parse a file to extract 3 digits numbers kept in a "group number"
I am trying to integrate in a single shell script a series of commands that
parse a european standard to extract a test sequence
convert the text encodings to utf8
process the result with the the awk routine that was provided to me on the post above.
save the content in a destination file
I have tentatively written the script below. I am able to achieve only step 1
and step 4
, but neither step 2
nor step 3
. I wonder if intermediate (temporary) file(s) should be created. I have tried to store the output of intermediate steps into variables, but without success. Any help also would be helpul regarding possible mistakes and the best way to do this.
#!/bin/bash
# creating the Latex code for a test procedure
awkcommand= "/usr/bin/awk
'
$1 == "Group" {printf("\\section{%s %d}\n", $1, $2); next}
{
title = sep = ""
for (i=1; i<=NF; i++)
if ($i ~ /^[0-9][0-9][0-9]$/) {
printf("\\subsection{%s} \n\\TestDetails{%d}\n", title, $i)
break
}
else {
title = title sep $i
sep = FS
}
}
'
"
sourcefolder="/Users/yves/Desktop/Test-folder-parsing/"
sourcefile="NFEN3545-001.pdf"
destfile="Latex-code.tex"
destfolder=$sourcefolder
destinationfilepath=${destfolder}${destfile}
extractioncmd="/usr/local/bin/pdftotext -layout -f 54 -l 54"
modifier=" -"
#textencodingcmd="/usr/bin/iconv -f L1 -t UTF-8" # Needed but not used
${extractioncmd} ${sourcefolder}${sourcefile} ${modifier} > $destinationfilepath
exit 0
[Add Comment]
button to see what is allowed in comments). (In that case you might be better of updating your original post).