I have the following: param="/var/tmp/test"
I need to replace the word test with another word such as new_test
need a smart way to replace the last word after “/” with sed
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Extracting bits and pieces with
sedis a bit messy (as Jim Lewis says, usebasenameanddirnameif you can) but at least you don’t need a plethora of backslashes to do it if you are going thesedroute since you can use the fact that the delimiter character is selectable (I like to use!when/is too awkward, but it’s arbitrary):We can also extract just the part that was substituted, though this is easier with two substitutions in the
sedcontrol script: