I have a string made up of directories with a space after each one
dirs="/home /home/a /home/b /home/a/b/c"
the following code deletes the last directory in the string.
dirs=${dirs% * }
This works in all cases except when only one directory is in the string, then it doesn't delete it because it doesn't have a space before it.
I'm sure there's an easy way to fix this, but i'm stuck.
I'd prefer a one line method without if statements if possible.
thanks