Wednesday 1 February 2017

UNIX Commands for DBAs

du -ah DIR

Sort smallest to biggest:
du -ah ~/Downloads/ | sort -h | head -6

biggest to smallest
du -ah ~/Downloads/ | sort -rh | head -6

Don't show me the directory, just the files:
du -ah ~/Downloads/ | grep -v "/$" | sort -rh | head -6

list of smallest to biggest, but the top 6 offending files
du -ah ~/Downloads/ | grep -v "/$" | sort -h | tail -6

find all files recursively, and sort them by size
find . -type f -print0 | xargs -0 ls -la | awk '{print int($5/1000) " KB\t" $9}' | sort -n -r -k1

list top-20 biggest files in the current directory recursively.
ls -1Rhs | sed -e "s/^ *//" | grep "^[0-9]" | sort -hr | head -n20
ls -1Rs | sed -e "s/^ *//" | grep "^[0-9]" | sort -nr | head -n20


Find the biggest directories:
du -ah . | sort -rh | head -20
du -a . | sort -rn | head -20


 scp your_username@remotehost.edu:foobar.txt /some/local/directory

scp * root@hlgedbt01.site03.mavenwire.com:/b01/rman_backups/OGEP/

Find directory Size
du -sh *

find ./test -name "*.php"

Count of files in folder
ls | wc -l

No comments:

Post a Comment