Useful Linux commands
Archives
Create:
tar cf archive.tar dir/
tar czf archive.tar.gz dir/
tar cjf archive.tar.bz2 dir/
tar czf archive.tar.gz dir/
tar cjf archive.tar.bz2 dir/
Extract:
# will work with tar, tar.gz, tar.bz2
# add -v to see extraction process
tar xf archive.tar.gz
# add -v to see extraction process
tar xf archive.tar.gz
Files
Delete:
# delete all files except *.ext:
find -not -name *.ext -type f | xargs rm -rf
#delete all directories except those that contain at least one file:
find -depth -type d -empty -exec rmdir {} \;
find -not -name *.ext -type f | xargs rm -rf
#delete all directories except those that contain at least one file:
find -depth -type d -empty -exec rmdir {} \;