cmp - compares two files
cmp file1 folder1/file2
no command output means file are identical
also compares the punctuation marks
reports only the fist difference found within the files.
diff path/file1 path2/file2
reports detail differences between two files
no command output means files are identical
sample output legends:
1c2 - line 1 from file1 changed to line 2 in file2
0a1 - add line 1 from file2 to line 0 (top of line 1) in file1
5d5- delete line 1 from file1 to gt line 5 from file2
diff command can tell which file is more complete by showing new lines within that file.
diff command is case sensitive by default
diff -i file1 file2 : disables case sensitivity.
diff -b file1 file2: ignores spaces, blanks and tabs while comparing
removes a file
Command to compress the large files
the one that are not used often are good selection for compression
when compressed '.z' extension is added to file.
once compressed you can't access file by its old name.
The ownership modes of original file are preserved when file is compressed
can compress more than one file at a time
e.g: compress file1 file2
compress -v *w*
the above command gives the verbose information of all the files that has 'w' in their name, about how much file is compressed.
this command may not compress some files , if file is too small or contains encrypted data.
Compression algorithm uses like pattern in files as basis for compression
compress -v -f file1
the above switch -f can be used to force compress the file1
force compression using -f can sometimes increase the size of the file after compression.
to uncompress the compressed file
using extension in command is optional
The wildcard * is useful to uncompress all files in directory
e.g: uncompress dir/*.z
uncompress -c filename1
above command writes the compressed or uncompressed files to standard output, but file isn't altered and remain compressed.
this can also be done using zcat command
e.g: zcat filename1.z
but zcat needs '.z' extension to be specified explicitly.
some files are written in binary code to send such file by mails, you have to encode it first
this can be done using following command
uuencode file1 - encodes executable file file1
uudecode file2 - decode file file2 that is encoded