Hi, I'm working on a program where a user inputs a directory name when the program is run. Sometimes when a user inputs the directory they leave a "/" at the end of it. I would like to catch this instance and remove the backslash.
So for example someone might input:
/home/examples/testDir/
This will get stored into variable: $l
I would like to find that last "/" and remove it.
As a side note, I would also like to find all instances where someone does not input a "/" at the beginning of the directory and add the "/". I'm sure if someone can help me with one of those situations I can figure out the other.
Thanks in advance.
So for example someone might input:
/home/examples/testDir/
This will get stored into variable: $l
I would like to find that last "/" and remove it.
As a side note, I would also like to find all instances where someone does not input a "/" at the beginning of the directory and add the "/". I'm sure if someone can help me with one of those situations I can figure out the other.
Thanks in advance.