task8 Write a bash script accepting three arguments: (url), (list file), and (ou
ID: 3745178 • Letter: T
Question
task8 Write a bash script accepting three arguments: (url), (list file), and (output). The script has to download from (url) all the files specified (one per line) in (list.file). Assume that all the files specified in (list file) are PDF files. Then, the script has to concatenate (maintaining the order specified in (list file)) all the downloaded files to generate a single PDF file. The resulting concatenated file must be saved in output) For instance, if the script is invoked in the following way: ./script.sh http://homepage.divms.uiowa. edu/"bianch/ task8list.txt output.pdf The script should generate a file called output.pdf, equal to task8samplesolution.pdf. You can find the files task8list.txt and task8samplesolution.pdf in the tar file of this homework I suggest using the command wget to download the files and the command pdftk to concatenate themExplanation / Answer
Please make sure you have pdftk and wget installed
Also since you haven't provided the links to the files specified here I am not able to test with those
#!/bin/bash
url=$1
filename=$2
wget --quiet -O $filename $url/$filename
finalfile=$3
wget --quiet -i $filename
file=''
while IFS= read -r var
do
file=`echo ${var##*/}`
done < "$filename"
echo $file
pdftk $file cat output $finalfile
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.