Christopher Buckley
Christopher Buckley

Reputation: 113

Bash Recursive search

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?

Upvotes: 0

Views: 136

Answers (1)

Anders Johansson
Anders Johansson

Reputation: 4006

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

Upvotes: 3

Related Questions