I have one variable var1=’common_location/specific_location_1/common_filename_text’ now I have to get a new variable var2=’common_location/specific_location_2/common_filename_text’.
How can I do it in a linux shell. I am novice in shell scripting. So please explain assuming I know a very little.
I have one variable var1=’common_location/specific_location_1/common_filename_text’ now I have to get a new variable var2=’common_location/specific_location_2/common_filename_text’.
Share
Use that:
where
var1is variable with/specific_location_1/common_filename_textstored in it.Below you can see that
var1andvar2differs only with one symbolSo we need just to substitute 1 to 2 and get new variable you need.
You can do it with :
Pretty easy.