I have a script where I want to find all direct subdirectories that is purely numerical in a folder and copy them to a specified destination. I have issues to get regexp to work with + and * in find. The folder structure in the example is as follows:
0/
1/
2/
3/
3.02asd/
3a/
4/
44/
45/
451/
452/
453/
4531/
4532/
45321/
45322/
45323/
666aa/
66a/
66aaa/
temp27/
I have gotten this to work with the following commands:
find . -type d -maxdepth 1 -name "[0-9]" | while read f
do
mv $f $TESTPATH
done
find . -type d -maxdepth 1 -name "[0-9][0-9]" | while read f
do
mv $f $TESTPATH
done
find . -type d -maxdepth 1 -name "[0-9][0-9][0-9]" | while read f
do
mv $f $TESTPATH
done
find . -type d -maxdepth 1 -name "[0-9][0-9][0-9][0-9]" | while read f
do
mv $f $TESTPATH
done
find . -type d -maxdepth 1 -name "[0-9][0-9][0-9][0-9][0-9]" | while read f
do
mv $f $TESTPATH
done
Not very nice but it works, but this should probably be possible with something like:
find . -type d -maxdepth 1 -name "[0-9]+"
or
find . -type d -maxdepth 1 -name "[0-9][0-9]*"
But it seems that + doesn't work and * is wildcard it seems.