Search code examples
bashfilepathtrim

Is it possible left and right bash trimming with the # and % operators in one command?


Is it possible to rewrite this piece of code

$ x="/foo/somefile.txt"
$ y=${x%.*}
$ echo ${y##*/}
somefile

without the variable y?

I mean like a one command with left and right trimming at one time.

Thanks!


Solution

  • Is it possible left and right bash trimming with the # and % operators in one command?

    No, it's not possible in bash.