Article 4TMH2 compare 2 filenames & move one to other's directory

compare 2 filenames & move one to other's directory

by
ericlindellnyc
from LinuxQuestions.org on (#4TMH2)
I have code that compares two files, & if equal, touches one with the other, so it has the same date.

This time, I'd like to compare the file names only, without the extension, and if equal, move one to the other's subdirectory.

This process makes the comparison for all files in two directories, iterating through one directory to find a match for each in the other directory, which it also iterates through, for a nested loop.

FILES=$( find ./nu/Mrj -type f ); for f in $FILES; do for g in ./ol/Mrj/*; do echo "f is $f g is $g"; if cmp "$f" "$g"; then echo "match"; touch -r $g $f; else echo "no match"; fi; done; done

Thanks in advancelatest?d=yIl2AUoC8zA latest?i=_Ti7-D2xXRQ:7I3EtI4xppg:F7zBnMy latest?i=_Ti7-D2xXRQ:7I3EtI4xppg:V_sGLiP latest?d=qj6IDK7rITs latest?i=_Ti7-D2xXRQ:7I3EtI4xppg:gIN9vFw_Ti7-D2xXRQ
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments