Concat Unix strings for file conversion in ksh

Posted on 2012-09-12
Last Modified: 2012-09-12
I have a file with one filename per line. Each filename has .html extension. I need to strip the extension, add a .ps extension and use both of those filenames as parameters to a conversion program. I can't get beyond syntax errors.

Currently I have:
DOCINPUTCMD="/usr/bin/htmldoc --webpage --footer ../ --headfootsize 9 --fontsize 9 --left 0.5in --right 0.3in --top 0.5in --bottom 0.5in -f

while read -r fullname
        echo $DOCINPUTCMD
        newfilename=`echo $fullname | cut -f1 -d'.'`
        usefile=`echo $newfilename".ps"`
        echo Executing ${DOCINPUTCMD} against file ${fullname} >> $MY_OUTPUT_FILE
        doitcmd=$DOCINPUTCMD $usefile $fullname
        echo '$doitcmd = ' $doitcmd
        $DOCINPUTCMD $usefile $fullname
        echo ${DOCINPUTCMD} $usefile $fullname

Open in new window

I want  to create something like:
htmldoc inputfilename.html

Open in new window

. Then I want to execute that command as well. Currently when I run the script I get this error: /gitst/home/gi/GI/scripts/[14]: syntax error at line 41 : `"' unmatched. This error is from the line assigning a string to the var usefile.
Question by:Bill Whiting
    LVL 68

    Expert Comment

    It's in line 1 - there's a missing terminating quote.

    DOCINPUTCMD="/usr/bin/htmldoc --webpage --footer ../ --headfootsize 9 --fontsize 9 --left 0.5in --right 0.3in --top 0.5in --bottom 0.5in -f"

    I assume you just didn't post the terminating "done < file_with_filenames" statement?

    Author Comment

    by:Bill Whiting
    That's correct, there were a couple of echo statements followed by:
      done < $INFILE
    LVL 68

    Expert Comment

    Did adding the terminating quote do the trick?

    Author Comment

    by:Bill Whiting
    No, but I wish it had. It was my error to leave the final line out of my question post, but it has been intact in my code all along.
    LVL 68

    Accepted Solution

    Sorry, I think we're not talking about the same thing.

    What I was referring to in my second comment is the first part of my first comment - about the missing terminating " in the first line you posted (the one starting with "DOCINPUTCMD"),  the quote which should have followed  -f

    Again, for your reference:

    DOCINPUTCMD="/usr/bin/htmldoc --webpage --footer ../ --headfootsize 9 --fontsize 9 --left 0.5in --right 0.3in --top 0.5in --bottom 0.5in -f"

    Author Closing Comment

    by:Bill Whiting
    Thanks, that was exactly the problem. Well worth the points to me so that I can get moving again. Now I see a problem with parameters to the htmldoc program, but that's another issue.


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Recently, an awarded photographer, Selina De Maeyer (, completed a photo shoot of a beautiful event ( in An…
    Every server (virtual or physical) needs a console: and the console can be provided through hardware directly connected, software for remote connections, local connections, through a KVM, etc. This document explains the different types of consol…
    Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
    Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…

    758 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    11 Experts available now in Live!

    Get 1:1 Help Now