This is the mail archive of the cygwin@cygwin.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

How to extract suffix from a filename?


Okay, it's a silly question - how can I extract the suffix from a file
name (I know I can use "basename" and "dirname" to get the file and
directory components)?

Read the rest of this mail message if you can be bothered.

I want to do this because my script executed from my .mailcap file in
mutt spawns off internet explorer or word or whatever other GUI thing is
required to read attachments like ".doc" and ".pps", etc. and I can keep
reading mail in mutt asynchronously.  To make this work I need to copy
the temporary file created by mutt and sometimes maybe this needs to end
in ".doc" and I would rather not hard-code the suffix in the script,
because, maybe somtimes, say for image/* mimetype, the suffix could be
".jpg" or ".tiff", etc. and maybe the invocation of IE5 requires the
target to end in ".jpg" or ".tiff" and it probably isn't right for me to
copy the "source.tiff" to "target.jpg" and start IE5 on the target.
Maybe.

I would like to use the suffix on the file supplied by mutt here,
instead of hard coding it.                                   |
                                                             |
                                                             |
                                                             |
                                            +----------------+
..                                         |
            application/vnd.ms-excel)       v
                TMPFILE=`mktemp $TEMPLATE`.xls
                COMMAND="/c/program\ files/microsoft\ office/office\
/excel \"`cygpath -a -w \"$TMPFILE\"`\"&"
            ;;
..
cp -fp "$SRCFILE" "$TMPFILE"
eval $COMMAND

***********************************************************************
This message has been checked for all known viruses by the
E-mail Virus Protection service, powered by MessageLabs.
***********************************************************************

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]