1

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:

CSAI_isotig00407:342-556
CSAI_isotig00408:342-556
.
.

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

CSAI_isotig00407:342-556_1.pdf
CSAI_isotig00408:342-556_2.pdf
4
  • Add an extract of this file to your question. Jun 15, 2016 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, 2016 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, 2016 at 10:27
  • and finlly merg all these files
    – TCFP HCDG
    Jun 15, 2016 at 10:27

1 Answer 1

3

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

So if filenames.txt contains

CSAI_isotig00407:342-556
CSAI_isotig00408:342-556

That command will effectively do

pdfunite CSAI_isotig00407:342-556_*.pdf CSAI_isotig00408:342-556_*.pdf output.pdf
1
  • 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 :-) Jun 15, 2016 at 12:57

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .