fish

fish shell: Is it possible to conveniently strip extensions?


Is there any convenient way to strip an arbitrary extension from a file name, something à la bash ${i%%.*}? Do I stick to my friend sed?


Solution

  • I want to delete this, but it's the accepted answer so I can't. This answer is very out of date. Don't use it.


    Nope. fish has a much smaller feature set than bash, relying on external commands:
    $ set filename foo.bar.baz
    $ set rootname (echo $filename | sed 's/\.[^.]*$//')
    $ echo $rootname
    foo.bar