I know how to find and concatinate pdf file. I did with the follwoing code.

pdfunite *.pdf output.pdf

But the problem is I have list of file names in one file say filenames.txt and I would like to search these files in the same folder and combine only these files. I tried to search on internet but could not find similar solution. I tried to use grep -wFf option to find

find | grep -wFf "fileames.txt\*.pdf" cat *.pdf

Does anybody have idea how can I do it? name file is as follows:


while the pdf files are with these name followed by 1,2,3.pdf

  • Add an extract of this file to your question. – garethTheRed Jun 15 '16 at 9:53
  • Actually the list in name file has more then one pdf file for each. These are differentiated with some numbers in the after the file name(that are in name file) – TCFP HCDG Jun 15 '16 at 10:25
  • So my intention is to take the first entry from the txt file and find all the pdf files that start with this name and do the same for all the entries in txt file. – TCFP HCDG Jun 15 '16 at 10:27
  • and finlly merg all these files – TCFP HCDG Jun 15 '16 at 10:27

pdfunite $(sed 's/$/_*.pdf/' filenames.txt) output.pdf

So if filenames.txt contains


That command will effectively do

pdfunite CSAI_isotig00407:342-556_*.pdf CSAI_isotig00408:342-556_*.pdf output.pdf
  • The $(...) sequence will run the mentioned command (in this case the sed command) and place the output on the command line. The sed statement will add an -*.pdf to the end of every line in the filenames.txt file. Combine the two and you get what you want :-) – Stephen Harris Jun 15 '16 at 12:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.