Last active
June 3, 2019 04:35
-
-
Save loru88/b4c4ed2cdf2c27202a09809338a013e7 to your computer and use it in GitHub Desktop.
Terminal Utils
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
## list content folder with size in human readable format | |
$ ls -lh | |
## file size in human readable format | |
$ du -h filename | |
## folder size in human readable format | |
$ du -msh folderName | |
## zip entire folder | |
$ zip -r myfiles.zip mydir | |
#or | |
$ tar -zcvf archive-name.tar.gz directory-name | |
## compress entire folder excluding some sub folder | |
$ tar --exclude='./folderName/subfolder2' --exclude='./folderName/subfolder1' -zcvf /backup/filename.tgz folderName | |
## uncompress folder | |
$ tar xf path/to/tar.gz -C path/to/destination/ | |
## download or upload file with scp | |
http://www.hypexr.org/linux_scp_help.php | |
# Copy the file "foobar.txt" from a remote host to the local host | |
$ scp [email protected]:foobar.txt /some/local/directory | |
# Copy the file "foobar.txt" from the local host to a remote host | |
$ scp foobar.txt [email protected]:/some/remote/directory | |
# delete folders older than 10 days | |
$ find /path/to/base/dir/* -type d -ctime +10 -exec rm -rf {} \; | |
$ find /path/to/base/dir/ -maxdepth 1 -mindepth 1 -type d -ctime +10 -exec rm -rf {} \; #my version | |
# check HTTP headers for connectivity to the internet | |
$ for i in `seq 1 20`; do curl -I http://www.example.com && sleep 10s; done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment