Quantcast
Viewing latest article 3
Browse Latest Browse All 4

Answer by evilsoup for Search for a files that matches another file name in another folder

Let's say you're in your $HOME, and you have four directories -- folderA and folderB, as in your question; folderK, where you want to move the 'kode' files to; and folderM, where you want to move your 'mode' folders to. The following should accomplish that:

shopt -s globstar
cd /path/to/folderA
for f in *_code_c*; do
  mv /path/to/folderB/**/"${f/code/kode}" /path/to/folderK
  mv /path/to/folderB/**/"${f/code_c/mode_m}" /path/to/folderM
done

Obviously test it out on some dummy data first.


Viewing latest article 3
Browse Latest Browse All 4

Trending Articles