My solutions to rustlings are kept in a branch in my fork of the repo (markgreene74/rustlings:solutions), and also in a separate repo rustlings_solutions. After a rebase of the branch to main some solutions need to be modified and the changes pushed.
This simple bash script can be used to find the file modified so that thay can also be updated in rustlings_solutions.
cd github
for src_file in $(find rustlings/exercises -type f -name "*.rs"); do \
dst_file=$(echo ${src_file} | sed 's/rustlings/rustlings_solutions/')
echo "Comparing ${src_file} and ${dst_file}";
diff ${src_file} ${dst_file} > /dev/null && echo "(OK) files are identical" || echo "${dst_file} differs" ;
echo; echo;
doneOr just replace the files that do differ.
for src_file in $(find rustlings/exercises -type f -name "*.rs"); do \
dst_file=$(echo ${src_file} | sed 's/rustlings/rustlings_solutions/')
diff ${src_file} ${dst_file} > /dev/null && echo OK || cp ${src_file} ${dst_file};
echo;
doneOriginally started to build on just find and xargs, but couldn't make it work.
find rustlings/exercises -type f -name "*.rs" -print0 | xargs -0I{} sh -c "echo {} && echo {} | sed 's/rustlings/rustlings_solutions/'"