Sample Header Ad - 728x90

Combining enscript, find, iconv and ps2pdf

0 votes
1 answer
1122 views
I'm trying to write a small bash script that'll convert source files in a directory to a .pdf. The steps are these - Locate files with find - execute iconv on the files converting the character encoding from utf-8 to iso-8859-1 via finds -exec - pass this output through enscript and eventually ps2pdf The only reason I've added iconv is that enscript does not support utf-8. So far I've made the following mess: #!/bin/bash enscript --portrait --columns=1 --header ' $n|'"$2"'|%F Page $% of $=' --highlight='java' --line-numbers --output='-' --color --font='Courier8' find $1 -name '*.java' -type f -exec iconv -f utf-8 -t iso-8859-1 {} + | ps2pdf - "$2"'.pdf' Running it give me this output: enscript: invalid option -- ',' Try `enscript --help' for more information. Edit: It did not give that error before I added -exec iconv. 2. edit: The original formulation I made was vague I see now. Heres the original script I tried to modify: #!/bin/bash which enscript --portrait --columns=1 --header ' $n|'"$2"'|%F Page $% of $=' --highlight='java' --line-numbers --output='-' --color --font='Courier8' find $1'/src/' -name '*.java' | ps2pdf - "$2"'.pdf' ./script.sh target_dir output_file_name The original script combines all source files in a folder recursively into one single pdf with each file starting at a fresh page. Maybe I just got to live with having to do this in two steps. First converting charset and then converting to pdf.
Asked by ndx (23 rep)
Feb 25, 2017, 10:34 PM
Last activity: Feb 26, 2017, 03:54 PM