I am trying the list all the subfolders within a folder:
find . -type d -maxdepth 1 -mindepth 1 2>/dev/null | while read dir
do
echo $dir
done
However, what I get printed out is
./dir1
./dir2
while I would need only
dir1
dir2
Complete use case:
later, I would like to create a new file with name of the folder e.g:
find . -type d -maxdepth 1 -mindepth 1 2>/dev/null | while read dir
do
echo 'MOVING TO'$dir
cd $dir
#SUMMARYLOG=$dir_log_merged # HERE IS WHERE THE ./ IS PROBLEMATIC
# QUESTION EDITED
SUMMARYLOG=${dir}_log_merged # HERE IS WHERE THE ./ IS PROBLEMATIC
echo -e "\n""\n"'SUMMARY LOGS TO '$SUMMARYLOG
touch $SUMMARYLOG
pwd
find . -size +0c -type f -name '*.err' | xargs -I % sh -c 'echo % >> {$SUMMARYLOG}; cat % >> "{$SUMMARYLOG}"; echo -e "\n" >> "{$SUMMARYLOG}"'
cat $SUMMARYLOG
cd ..
done
Basically, I would like to merge a set of .err
files in each of the subfolders and create one file with the subfolder name.
I can not create my $SUMMARYLOG
so I think the problem is in the find output ./dir
...