UNIX commands and Notes

Summarize the size of a group of gz files:

ls -l *.gz | awk '{sum += $5} END {print sum}'


Remote and local file syncronization. Given two directories dir1 and dir2, you can synchronize the contents of dir2 to dir1 as follows:

rsync -a dir1/ dir2

The trailing slash on dir1 ensures that the contents of dir1 are transferred but not dir1 itself. Two other useful flags:

rsync -avn dir1/ dir2

v = verbose, n = dry-run

rsync to a remote machine

rsync -a local_dir username@remote_host:destination_directory

-P option will give you a progress bar, and in case of an interrupted transfer will also allow you to resume later.

other options




deletes files from destination that are not present locally (true sync)


specify a pattern to include


specify a pattern to exclude

UNIX (last edited 2015-09-23 14:07:46 by ChrisSeidel)