The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Stripping out extension in file name devs Shell Programming and Scripting 9 05-14-2008 01:53 AM
Truncate multiple file extensions prvnrk Shell Programming and Scripting 12 04-04-2008 07:20 AM
Stripping out the extension of a file name ramky79 Shell Programming and Scripting 2 12-27-2006 11:25 AM
find -regex: matching multiple extensions r0sc0 Shell Programming and Scripting 2 12-08-2005 11:32 AM
stripping last lien off a file vivekshankar UNIX for Dummies Questions & Answers 3 05-31-2005 03:35 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #8  
Old 05-14-2008
Moderator
 

Join Date: Feb 2007
Posts: 2,314
Quote:
Originally Posted by Nemelis View Post
What he could not explain to me is why it finds the last dot in test.foo.extension and not the first dot (thus why it actually works). Since both "any number of characters" may contain dots (in theory) if I understand the man-pages (and his explanation) correctly.
In the sed command there is a saved substring "\(.*\)" wich we want and is recalled with "\1".
After this pattern we have "\..*" wich means a dot and everything after it.
Sed uses a greedy match (AKA longest match) so the saved substring will contain the part before the last "." in the substring.

Regards
Reply With Quote
Forum Sponsor
  #9  
Old 05-14-2008
era era is offline
Herder of Useless Cats
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 3,650
Quote:
Originally Posted by danmero View Post
echo can do the job, anything else is useless.
Code:
FNAME=`echo "${FILE_NAME%.*}"`
Actually, the echo is quite useless, too.

Code:
FNAME=${FILE_NAME%.*}
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 12:15 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0