How to remove trailing slash in a file path on linux shell

We sometime may require to remove a trailing slash entered by a user as part of some file path in linux systems. The trailing slash can be removed using pattern matching

ex :

$ MYPATH=/home/user1/desktop/

$ echo ${MYPATH%/}

The output will be like :   /home/user1/desktop


Popular posts from this blog

How to disable USB ports on Mac OS X Mavericks, Yosemite or El Capitan ?