![]() I actually wrote that command for this specific use case, which I encounter frequently and have been using it as a bash/ zsh function for a long time, which I named chext: chext() /")" I realize OP tagged bash specifically, and for that reason, the accepted answer will work just fine, but if you wanted to use this command in a shell script on a system using sh or dash, you could use the version I posted above, which utilizes any version of sed (GNU/BSD/anything), and will work just fine, while not relying specifically on bash itself. ![]() ![]() You can go here to see all the reasons why this method is better than all the other answers, but basically, the accepted answer is not POSIX-compliant since it relies on bash parameter expansion. I am posting this because I have not seen another answer that details this method and why it could potentially be superior to the accepted answer. ![]()
0 Comments
Leave a Reply. |