I have started to make a script that will recursively search through the files in a folder. What I need to do is compare them with the modified times in another folder. I currently have a string like compare1/folder/file.ext but I now need to tell it to do compare2/folder/file.ext. How would I change the base folder so I can compare the file?
Add a comment
|
1 Answer
Still not 100% sure what you're looking for, but if you want to replace a string in a variable, you can do:
FILE=compare1/folder/file.ext
OTHER_FILE=${FILE//compare1/compare2} # replace compare1 with compare2
echo $OTHER_FILE # will print compare2/folder/file.ext
4 Comments
Christopher Buckley
Thanks, this seems to be what I need.
Chris Seymour
You should accept this answer to show the question is solved, and to give thanks for the answer. +1 for deciphering first.
Christopher Buckley
I would give thanks but I need 15 rep so marking it as the answer will have to do.
Chris Seymour
I upvoted one of your other questions, you now have enough reputation to upvote any answer you have found helpful on the site.