2011-10-11

*nix tips

Find all unique ip addresses from webserver logs:
# awk '{print $1}' access.log | sort | uniq
# zcat access.log.gz | awk '{print $1}' | sort | uniq

Copy files using tar (this preserves metadata. add 'p' option to also preserve ownership data):
# cd source-dir
# tar cSf - . | tar xSf - -C target-dir

Count total size in bytes of files in current directory tree (different from disk usage):
# find . -type f -ls | awk '{total += $7} END {print total}'

No comments:

Post a Comment