Question : Shell script to move files matching a pattern, and keeping the same tree structure

Hi

I would like to write a shell script that would move files matching the pattern *_t.* to another location, while keeping the directory structure from the original location.

Can someone help ?

Answer : Shell script to move files matching a pattern, and keeping the same tree structure

OK, I'm now having access to a linux machine.
Here's the fixed version:
1:
2:
3:
4:
5:
6:
7:
8:
9:
#!/bin/sh
 
basedir=/source
destdir=/destination
 
for file in $(cd $basedir && find . -type f -name "*_t.*"); do
  mkdir -p $destdir/$(dirname $file)
  mv $basedir/$file $destdir/$file
done
Open in New Window Select All
Random Solutions  
 
programming4us programming4us