I want to iterate through all the folders present in path3 and then get all the files inside them at depth of 1 and make a single tar from them, I am trying something like this:
<code> path3=A/B/C
if [$length != 0 ];then
for dir in $(find "$path3" -type d)
do
find $dir -maxdepth 1 -type f | tail -2
done
xargs tar cvfz mpe-tar/$i/part_2.tgz
fi
</code>
<code> path3=A/B/C
if [$length != 0 ];then
for dir in $(find "$path3" -type d)
do
find $dir -maxdepth 1 -type f | tail -2
done
xargs tar cvfz mpe-tar/$i/part_2.tgz
fi
</code>
path3=A/B/C
if [$length != 0 ];then
for dir in $(find "$path3" -type d)
do
find $dir -maxdepth 1 -type f | tail -2
done
xargs tar cvfz mpe-tar/$i/part_2.tgz
fi
But tar is not getting created , how to pass the output from for loop to xargs and get the tar?
I am expecting tar file containing all the files at depth 1 for each folders in path3.
New contributor
Prashant Kumar Jha is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.