File Ops Flashcards
What is the ‘diff’ tool used for?
Comparing files line by line
What is the ‘cmp’ tool used for?
Comparing files byte by byte
What syntax do ‘diff’ & ‘cmp’ use to compare files?
[diff | cmp] filename1 filename2
What is the ‘tar’ command used for?
Bundling multiple files into a single file called a ‘tarball’ without compression
What is the ‘gzip’ command used for?
Creating compressed archives of multiple files
How can archives compressed with ‘gzip’ be unzipped?
‘gzip -d’ or by using ‘gunzip’
How can ‘tar’ and ‘gzip’ be effectively used together?
‘tar’ file bundles can be compressed using ‘gzip’ to make sending large file archives more efficient
What command creates a tarball?
tar cvf archive.tar /path/to/files
How do you extract files from a tarball?
tar xvf archive.tar
How do you ‘gzip’ a tarball?
gzip archive.tar
How do you unzip a gzipped tarball?
gzip -d archive.tar.gz
What is the ‘truncate’ tool used for?
To shrink or extend the size of a file
Can ‘truncate’ be used for compression?
No, truncate is destructive so shrinking a file will cause data loss
How can ‘truncate’ be used to shrink or extend a file?
truncate -s num_bytes filename (num_bytes can be smaller than the file to shrink it or greater than the file to extend it)
What is the ‘cat’ command used for?
Sending the contents of a file to an output stream and concatenating multiples files together
How can multiple files be concatenated into a new file using ‘cat’?
cat file1 file2 file3 > file4
What is the ‘split’ command used for?
Splitting the contents of a large file into multiple smaller files
How can a single file be split into multiple smaller files using ‘split’?
split -l num_lines filename split_file_prefix
How does naming work when using ‘split’?
A file name prefix is provided when splitting the files. Split files are then named prefix + {aa..az} then {ba..bz} then {ca..cz} etc