I am trying to make a script that will archive all the folders (except NOARCHIVE folder) and then remove those folders:
cd my_specific_folder;
for f in *; do
if [ -d $f -a $f != "NOARCHIVE" ]; then
tar czf $f.tar.gz $f && rm -r $f;
fi;
done && echo "All the folders within my_specific_folder are archived.";
There are around 150 folders and I get the following error: Too many arguments. I tried using find . | xargs but unsuccessfully.
cd my_specific_folder;
for f in *; do
if [ -d "$f" -a "$f" != "NOARCHIVE" ]; then
tar czf "$f".tar.gz "$f" && rm -r "$f";
fi;
done && echo "All the folders within my_specific_folder are archived.";
Then re-run the code and check if that fixes the issue.
If that's not the case, please post the exact command and output/error message that you're getting.