cut file extension
Heinrich Rebehn
rebehn at ant.uni-bremen.de
Wed Feb 20 14:12:49 UTC 2008
Owen Townend wrote:
> On 2/20/08, David Restall - System Administrator <dave at restall.net> wrote:
>> Hi,
>>
>>> On 2/20/08, Germain Morbe <germain.morbe at web.de> wrote:
>>>> Hi all,
>>>>
>>>> im looking for a solution to strip the file extension
>>>> within a bash script.
>>>>
>>>> thanks
>>>>
>>>> --
>>>> ubuntu-users mailing list
>>>> ubuntu-users at lists.ubuntu.com
>>>> Modify settings or unsubscribe at:
>>>> https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
>>>>
>>> Hey,
>>> Look into `sed`. Something like this should do it
>>> `sed -e 's/.*$//'`
>>>
>>> That's from the top of my head though, check it first!
>> man basename may be useful :-)
>>
>> and the Owen's sed command isn't quite right, use 's/\..*$//'.
>>
>> The cut command could also be used using a delimter of . and so could
>> awk. TMTOWTDI :-)
>>
>> TTFN
>
>
> ahah, that's closer to what I was aiming for, but it still doesn't
> account for files like '
> file.name.ext' cutting them to 'file' though it should only match the end
> of the line... ?
>
$ file=file.name.ext
$ echo ${file%.*}
file.name
Is that what you want? :-)
-Heinrich
More information about the ubuntu-users
mailing list