Get the number of files
ls . | wc -l ls /foo/*.imgs | wc -l
Get the disk size of folder
du -hs ./datasets
Create and delete files
touch foo.txt mkdir a_folder rm foo.txt rm -r a_folder
Compress and Uncompress:
tar -cvzf a_folder.tar.gz a_folder tar -xvzf a_folder.tar.gz # uncompression
Split and Concat:
split -b 1024m -d --verbose a_folder.tar.gz a_folder.tar.gz.part_ cat a_folder.tar.gz.part_* > a_folder.tar.gz
-b: split file by size. (use
-n to split by number)
-d: use numeric suffixes starting at 0, not alphabetic;
Copy huge amount of files
rsync -ahW --no-i-r --info=progress2 source destination
-a: keep file information, including owners, permissions, etc.
-h: make output human-readable.
-W: copy files whole (w/o delta-xfer algorithm), faster.
--no-i-r: scan files before copying, rather than at the same time. Faster when lots of files.
--info=progress2: display a progress bar.
--dry-run: perform a trial run that doesn’t make any changes (and produces mostly the same output as a real run).
destination: the source file/folder and destination folder.
source/: If a trailing slash added, the content in
source will be copied into the
destination. So if
destination doesn't exist or is empty, this works like a combination of copy and rename.