Add Comment
|
Related Links
|
TrackBack
Extension.sh (GPL)The UNIX command "basename" is a wonderful tool. When you specify a path, it will tell you the file name. If you specify a suffix (or an extension), it can trim that from the file name. The only problem is that there isn't an UNIX command for telling you the extension of a file. And if you don't know the extension of the file, then you can't tell "basename" the correct suffix to remove. So I have written this Extension.sh script. This script can tell you the extension of the file name you specified as a path. If the file name has no extension, then it returns an empty string. Extension.sh takes advantage of the Token.sh (GPL) and the Tokenize.sh Bourne shell scripts. These scripts are all available on this site. So to use Extension.sh, you will need to download the these other scripts if you don't already have them. Extension.sh is distributed as executable source code under the GNU General Public License. Please see the license agreement elsewhere on this site. Chieh Cheng After using this Extension.sh script for a few days, I found two cases where this script would fail: 1) when the file name contains one or more spaces; and 2) when the file name has more than one period. So I have fixed those problem in this latest version of Extension.sh. Now the spaces will not effect the output. And when there is more than one periods, Extension.sh returns the extension from the end of the last period. In addition, the first period in file names that starts with a period are ignored. UsageExtension.sh "path" Examples> Extension.sh Extension.sh Chieh Cheng
Add Comment
|
Related Links
|
TrackBack
Did your message disappear? Read the Forums FAQ. Add CommentSpam Control | * indicates required field TrackBackTrackBack only accepted from WebSite-X Suite web sites. Do not submit TrackBacks from other sites. Send Ping | TrackBack URL | Spam Control No TrackBacks yet. TrackBack can be used to link this thread to your weblog, or link your weblog to this thread. In addition, TrackBack can be used as a form of remote commenting. Rather than posting the comment directly on this thread, you can posts it on your own weblog. Then have your weblog sends a TrackBack ping to the TrackBack URL, so that your post would show up here. Messages, files, and images copyright by respective owners. |
Products
|
Services
99 Users Online
|
Copyright © 1996 - 2025. All Rights Reserved. |