[MLIST] [olug] sed and sh

David Walker linux_user at grax.com
Tue Feb 4 21:18:46 UTC 2003


I can't see why it happens offhand but I can recommend a different way to do 
it that may be more reliable.

If you can depend on the file name being in the format "recvq/fax00022.tif" 
then you can pull the character in at the correct position in that string
TRUNCFILE=${FILE:6:${#FILE}-10}
#(fixed starting point and an extension of 4 characters)


On Tuesday 04 February 2003 03:13 pm, Jon H. Larsen wrote:
> I'm currently modifying a script that came with Hylafax where I am
> attaching a PDF version of the Tif fax document to an email, and
> delivering it.
>
> I created a TEST script to work on the bit of code that I need to truncate
> the filename.
>
> #!/bin/sh
> #
> # trunctest.sh
>
>
> FILE="$1"
> TRUNCFILE=`echo $FILE | /bin/sed -e 's/recvq\///' | /bin/sed -e
> 's/\.tif//'`
>
> echo $TRUNCFILE
>
>
> Run it like so:
> ../trunctest.sh recvq/fax00022.tif
>
> output:
> fax00022
>
> Works great.
>
> When I stick the lines in the production faxrcvd script, output is always
> blank.
>
> FILE="$1"
> TRUNCFILE=`echo $FILE | /bin/sed -e 's/recvq\///' | /bin/sed -e
> 's/\.tif//'`
>
> $TRUNCFILE is only used in echo statements in the script, and is only
> defined once.
>
> I've tried to use some of the PDF scripts provided by another source, but
> they didn't work as I had expected them.  This truncate issue is the only
> thing holding me back from putting fax receive into production in our
> environment (send has been running for a year now).  The script will
> deliver a PDF, but I'd rather have a more descriptive filename other than
> ".PDF" on the attachment. :)
>
> Puzzled...
> Jon L.




More information about the OLUG mailing list