Do you know the extension ahead of time? If so, you can use 'basename'.

FILE=path/foo.txt
BASE="$(basename "$FILE" .txt)"

It also strips off the path so BASE is now "foo".
If you want the directory you can use 'dirname'.


On Mon, Dec 31, 2012 at 12:54 AM, William Ehrich <[email protected]> wrote:
> I'm trying to write a shell script (in a tcsh) which uses a filename
> argument without its extension:
>
>   filename=$1:r
>   echo filename
>
> doesn't work. What is the right way to do it?
> _______________________________________________
> MacOSX-talk mailing list
> [email protected]
> http://www.omnigroup.com/mailman/listinfo/macosx-talk



-- 
arno  s  hautala    /-|   [email protected]

pgp b2c9d448
_______________________________________________
MacOSX-talk mailing list
[email protected]
http://www.omnigroup.com/mailman/listinfo/macosx-talk

Reply via email to