James Starlight
James Starlight

Reputation: 523

bash: excluding found files located in the subdirs

My script looks for the files of trr extension and then copy it to the target dit, (all_trr)

dir=$(pwd)



traj_ext='trr'

# save the data into:
all_trr=${dir}/PCA

# refresh PCA folder
if [ -d "${all_trr}" ]; then
  rm -rf "${all_trr}"
  mkdir "${all_trr}"
else
  mkdir "${all_trr}"
fi

#find trajectories in trr and copy it to $all_trr
find "$dir" -maxdepth 2 -name "*.${traj_ext}" -exec mv {} "$all_trr" \; # -not -path "${all_trr}"

the problem that the script find already moved trr filles and gives me warning that we are tried to move the same file

mv: '/home/user/Bureau/NMR_Analyse/BAK_MDtest_ultimo/PCA/prod_MD_BAK_360deg_300K.trr' et '/home/user/Bureau/NMR_Analyse/BAK_MDtest_ultimo/PCA/prod_MD_BAK_360deg_300K.trr' identifient le même fichier

To fix it I have tried to add

-not -path "${all_trr}"

but it did not solve the issue !

Upvotes: 0

Views: 47

Answers (0)

Related Questions