Skip to content

Instantly share code, notes, and snippets.

@dcode
Last active February 29, 2016 17:02
Show Gist options
  • Select an option

  • Save dcode/d101ee12ab7b0127e30c to your computer and use it in GitHub Desktop.

Select an option

Save dcode/d101ee12ab7b0127e30c to your computer and use it in GitHub Desktop.
I use this to archive an entire directory (by subdirectory) and compress with 7zip. I run this occasionally on my "projects" dir to cleanup old space.
#!/bin/bash
for item in $(find . -type d -depth 1 | grep -Ev 'dir|names|toexclude'); do
tar cvf - ${item} | 7za a -si ${item}.tar.7z;
rm -rf ${item};
done
#!/bin/bash
for item in $(find . -type f -depth 1 -name '*.tar.7z' | grep -Ev 'names|to|exclude'); do
7za x -so ${item} | tar xf -;
rm -f ${item};
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment