0

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?

1 Answer 1

3

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
Sign up to request clarification or add additional context in comments.

4 Comments

Thanks, this seems to be what I need.
You should accept this answer to show the question is solved, and to give thanks for the answer. +1 for deciphering first.
I would give thanks but I need 15 rep so marking it as the answer will have to do.
I upvoted one of your other questions, you now have enough reputation to upvote any answer you have found helpful on the site.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.