# How to get the last dirname/filename in a file path argument in Bash?

LinuxOperating SystemOpen Source

We make use of the bash files to store different variables that we normally refer to as the environment variables. We can later access these variables easily by just printing them with the help of the echo utility command tha linux provides us with.

## Output

bin

We can also use a short trick to get the second-last values by modifying the base name command to something like this −

## Output

immukul
Published on 30-Jul-2021 08:33:19