Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT sources DOT redhat DOT com Delivered-To: mailing list cygwin AT sources DOT redhat DOT com X-VirusChecked: Checked Date: Tue, 26 Jun 2001 10:38:17 +0100 From: "malcolm.boekhoff" To: Cygwin News Group Subject: How to extract suffix from a filename? Message-ID: <20010626103817.A221@BOEKHOFF_M> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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/