Skip to main content
added 164 characters in body
Source Link
Coren
  • 5.1k
  • 1
  • 27
  • 44

You can add a continue statement like this :

cd /var/www
for dir in */
do
        if [ "$dir" == "foo" ] ; then
              continue;
        fi
        base=$(basename "$dir")
        tar -czfh "${base}.tar.gz" "$dir"
done

Or you can do it with find command :

find /var/www -maxdepth 1 -type d \( -name foo \) -prune -o -print -exec bash -c "tar -czfh \`basename {}\`.tar.gz {}" \;

You can add a continue statement like this :

cd /var/www
for dir in */
do
        if [ "$dir" == "foo" ] ; then
              continue;
        fi
        base=$(basename "$dir")
        tar -czfh "${base}.tar.gz" "$dir"
done

You can add a continue statement like this :

cd /var/www
for dir in */
do
        if [ "$dir" == "foo" ] ; then
              continue;
        fi
        base=$(basename "$dir")
        tar -czfh "${base}.tar.gz" "$dir"
done

Or you can do it with find command :

find /var/www -maxdepth 1 -type d \( -name foo \) -prune -o -print -exec bash -c "tar -czfh \`basename {}\`.tar.gz {}" \;
Source Link
Coren
  • 5.1k
  • 1
  • 27
  • 44

You can add a continue statement like this :

cd /var/www
for dir in */
do
        if [ "$dir" == "foo" ] ; then
              continue;
        fi
        base=$(basename "$dir")
        tar -czfh "${base}.tar.gz" "$dir"
done