How to manipulate path elements in shell