Comparing two files in Unix to pinpoint their differences is a common task for developers, system administrators, and anyone working with text-based data. compare.edu.vn offers comprehensive guides on various file comparison techniques, helping you identify discrepancies efficiently. By exploring methods like diff
, comm
, and grep
, you can effectively manage and reconcile file versions.
1. What Is The Most Basic Way To Compare Two Files In Unix?
The most basic way to compare two files in Unix is using the diff
command. The diff
command analyzes files line by line and outputs the differences between them, including insertions, deletions, and changes.
The diff
command is a fundamental tool in Unix-like operating systems for identifying discrepancies between two files. By comparing the files line by line, diff
highlights the exact locations where the files diverge, making it easy to spot insertions, deletions, and modifications. The output is typically presented in a format that indicates the type of change (addition, deletion, or change) and the affected lines. For instance, if a line exists in the first file but not in the second, diff
will denote this as a deletion. Conversely, if a line is present in the second file but absent in the first, it will be marked as an insertion. When a line has been altered, diff
indicates the change and displays both the original and modified versions. This level of detail is invaluable for tracking revisions, merging code, and ensuring file integrity.
diff file1.txt file2.txt
This command will output the differences between file1.txt
and file2.txt
.
2. How Can You Use The comm
Command To Compare Files?
You can use the comm
command to compare two sorted files line by line, outputting lines unique to each file and lines common to both. The comm
command is used to compare two sorted files and produce three columns of output: lines unique to the first file, lines unique to the second file, and lines common to both files.
To compare file1.txt
and file2.txt
, ensure both files are sorted first:
sort file1.txt > sorted_file1.txt
sort file2.txt > sorted_file2.txt
Then, use the comm
command:
comm sorted_file1.txt sorted_file2.txt
This will output three columns: lines unique to sorted_file1.txt
, lines unique to sorted_file2.txt
, and lines common to both files. You can suppress columns using options like -1
, -2
, and -3
. For example, to show only lines present in file1.txt
but not in file2.txt
:
comm -23 sorted_file1.txt sorted_file2.txt
The comm
command is particularly useful when you need to identify the similarities and differences between two lists, configuration files, or sets of data. It’s important to note that comm
requires the input files to be sorted; otherwise, the output may not be accurate. Sorting the files before comparison ensures that comm
can correctly identify the common and unique lines. This makes comm
a powerful tool for tasks such as comparing software versions, identifying changes in configuration settings, and analyzing datasets.
3. Can grep
Be Used To Find Lines In One File But Not Another?
Yes, grep
can be used to find lines in one file but not another by using the -v
(invert match) and -f
(file) options. This allows you to identify lines that exist in the first file but are absent in the second.
To find lines in file1.txt
that are not in file2.txt
, you can use the following command:
grep -v -f file2.txt file1.txt
Here, the -f file2.txt
option tells grep
to read patterns from file2.txt
, and the -v
option inverts the match, so it only outputs lines from file1.txt
that do not match any lines in file2.txt
. This method is effective for identifying unique entries in a primary file compared to a secondary file. For example, this can be used to find configuration settings that are present in a default configuration file but have been removed or modified in a custom configuration file. Similarly, it can be used to identify user accounts that exist in one system but not in another. The grep
command offers a versatile approach to file comparison, particularly when dealing with scenarios where you need to isolate specific differences.
4. What Are Some Advanced Techniques For File Comparison In Unix?
Advanced techniques for file comparison in Unix include using rsync
for synchronizing files and directories, employing scripting languages like awk
or perl
for custom comparisons, and utilizing specialized tools like vimdiff
or graphical diff tools.
-
rsync
: While primarily used for synchronizing files between locations,rsync
can also be used to identify differences. The-n
(dry-run) and-v
(verbose) options can show what would be transferred without actually making any changes:rsync -nv file1.txt file2.txt
-
awk
: Theawk
command allows you to perform more complex comparisons by processing files line by line and applying custom logic:awk 'FNR==NR{a[$0];next} !($0 in a)' file2.txt file1.txt
This command prints lines from
file1.txt
that are not infile2.txt
. -
perl
: Perl provides powerful text processing capabilities, making it suitable for advanced file comparisons:perl -ne 'chomp; if (! $seen{$_}++) { print "$_n" }' file2.txt file1.txt
This script prints lines from
file1.txt
that are not infile2.txt
. -
vimdiff
: Thevimdiff
tool is a visual diff utility within the Vim editor that displays two or more files side by side, highlighting the differences:vimdiff file1.txt file2.txt
*Graphical Diff Tools**: Graphical tools like Meld, Kompare, and DiffMerge offer user-friendly interfaces for comparing files and directories. These tools typically provide features such as side-by-side comparison, syntax highlighting, and the ability to merge changes interactively. These tools often enhance readability and ease of use compared to command-line tools, especially when dealing with complex or large files. For instance, graphical diff tools are particularly helpful for comparing source code, configuration files, and documents, where visual cues can aid in quickly identifying and resolving discrepancies. By providing a clear visual representation of the differences, these tools streamline the process of file comparison and make it more accessible to users with varying levels of technical expertise.
These advanced techniques offer more flexibility and control over the file comparison process, allowing you to handle complex scenarios and specific requirements efficiently. Whether you need to synchronize directories, perform custom comparisons, or visualize differences, Unix provides a range of tools to meet your needs. For example, using awk
or perl
allows you to compare specific fields within a file, ignoring other parts, or to perform calculations based on the differences. Graphical diff tools are invaluable for tasks such as code review, where you need to quickly understand the changes made between versions.
5. How Do You Compare Binary Files In Unix?
Comparing binary files in Unix requires using specialized tools like cmp
or hexdump
because standard text-based comparison tools are ineffective. The cmp
command compares two files byte by byte and reports the first difference found. The hexdump
command displays the contents of a file in hexadecimal or other formats, allowing you to visually inspect the data.
-
cmp
Command: Thecmp
command is the simplest way to compare two binary files. It stops at the first difference:cmp file1.bin file2.bin
If the files are identical,
cmp
will produce no output. If they differ, it will report the byte and line number of the first difference. -
hexdump
Command: Thehexdump
command allows you to view the contents of binary files in hexadecimal format, which can be useful for identifying patterns and differences:hexdump file1.bin | less hexdump file2.bin | less
You can then visually compare the hexadecimal output to identify any differences.
-
xxd
Command: Thexxd
command is another utility for creating a hex dump of a file, or converting a hex dump back to binary:xxd file1.bin | less xxd file2.bin | less
Like
hexdump
, you can use it to inspect and compare binary files. -
bcompare
Command: Thebcompare
command is part of the Beyond Compare tool, which is a powerful GUI-based comparison tool that can handle both text and binary files. It provides a visual interface for comparing binary files, making it easier to identify differences.
These tools provide different approaches to comparing binary files, allowing you to choose the method that best suits your needs. For example, cmp
is useful for quickly checking if two files are identical, while hexdump
and xxd
are useful for detailed inspection and comparison of the file contents. Beyond Compare offers a more user-friendly visual comparison, which can be helpful for complex binary files.
6. How Can You Ignore Case When Comparing Files In Unix?
You can ignore case when comparing files in Unix using the -i
option with the diff
or grep
commands. This ensures that the comparison is case-insensitive, treating uppercase and lowercase letters as equivalent.
-
Using
diff
: Thediff
command can ignore case differences with the-i
option:diff -i file1.txt file2.txt
This command compares
file1.txt
andfile2.txt
while ignoring case, so lines that differ only in case will not be reported as different. -
Using
grep
: When usinggrep
to find lines in one file that are not in another, you can add the-i
option to ignore case:grep -i -v -f file2.txt file1.txt
This command finds lines in
file1.txt
that are not infile2.txt
, ignoring case.
Ignoring case is particularly useful when comparing files where the case of letters is not significant, such as configuration files or text documents where capitalization may vary. For instance, when comparing two versions of a configuration file, you might want to ignore case differences to focus on other changes. Similarly, when searching for specific strings in a file, ignoring case can help you find matches regardless of capitalization. The -i
option with diff
and grep
provides a simple and effective way to perform case-insensitive comparisons, making these tools more versatile.
7. What Is The Best Way To Compare Large Files In Unix?
The best way to compare large files in Unix involves using tools like cmp
, diff
, or rsync
efficiently, along with techniques such as splitting files or using memory-efficient algorithms to handle large data volumes. When comparing large files, memory usage and processing time become critical factors.
-
cmp
Command: Thecmp
command is very efficient for large files because it stops at the first difference:cmp large_file1.txt large_file2.txt
This command is suitable if you only need to know if the files are identical or where the first difference occurs.
-
diff
Command: For more detailed comparisons,diff
can be used, but it may be slower and consume more memory:diff large_file1.txt large_file2.txt
To improve performance, consider using the
-s
option to only report if files differ without showing the actual differences. -
Splitting Files: Splitting large files into smaller chunks can help manage memory usage. The
split
command can be used for this purpose:split -l 10000 large_file1.txt chunk_
This command splits
large_file1.txt
into smaller files with 10,000 lines each, namedchunk_aa
,chunk_ab
, etc. You can then compare these smaller files individually. -
rsync
for Synchronization: If you need to synchronize large files or directories,rsync
is an excellent choice. It uses efficient algorithms to minimize data transfer:rsync -avz large_file1.txt large_file2.txt
*Memory-Efficient Algorithms**: For custom comparisons, consider using scripting languages like Python or Perl with memory-efficient algorithms. For instance, reading files line by line instead of loading the entire file into memory can significantly reduce memory usage. Additionally, you can leverage libraries such as
mmap
in Python to memory-map files, allowing you to access portions of the file as if they were in memory without actually loading the entire file. Tools likecsdiff
are designed to compare large files more efficiently than standard diff.
Choosing the right tool and technique depends on the specific requirements of the comparison. For simple checks of equality, cmp
is the fastest. For detailed comparisons, diff
can be used with consideration for memory usage. Splitting files and using memory-efficient algorithms are essential for handling very large files.
8. How Can You Compare Directories For Differences In Unix?
You can compare directories for differences in Unix using the diff
command with the -r
option for recursive comparison or the rsync
command for synchronizing directories. The diff
command identifies differences between files in two directories, while rsync
can synchronize the contents, making it easy to spot discrepancies.
-
Using
diff
: To compare two directories recursively, use the-r
option:diff -r dir1 dir2
This command compares all files and subdirectories in
dir1
with those indir2
. It will output a list of differences, including files that exist only in one directory, files that are different, and subdirectories that contain differences. -
Using
rsync
: Thersync
command is useful for synchronizing directories and identifying differences:rsync -nv --delete dir1/ dir2/
The
-n
option (dry-run) shows what would be transferred without actually making any changes. The--delete
option shows files that would be deleted from the destination directory to match the source directory. The-v
option provides verbose output, listing the files being compared. -
Using
dircmp
: Thedircmp
command is specifically designed for comparing directories, displaying information about files that are present in both directories, files that are unique to each directory, and files that have different content:dircmp dir1 dir2
-
Using
find
andgrep
: You can usefind
to list files in each directory and then usegrep
to find files that are present in one directory but not the other:find dir1 -type f > dir1_files.txt find dir2 -type f > dir2_files.txt grep -v -f dir2_files.txt dir1_files.txt
This will show files that are in
dir1
but not indir2
.
These methods provide different ways to compare directories, allowing you to choose the one that best suits your needs. The diff -r
command is useful for identifying all differences, while rsync
is ideal for synchronizing directories and spotting discrepancies. Using find
and grep
offers a more manual approach, allowing you to customize the comparison process. For example, you can use find
to filter files based on specific criteria, such as modification time or file size, before comparing them.
9. What Options Can Be Used With The diff
Command For More Granular Control?
Several options can be used with the diff
command for more granular control, including -i
for ignoring case, -w
for ignoring whitespace, -b
for ignoring changes in whitespace quantity, and -u
for creating unified diffs. These options allow you to customize the comparison process to focus on specific types of differences.
-
-i
(Ignore Case): Ignores case differences:diff -i file1.txt file2.txt
-
-w
(Ignore Whitespace): Ignores all whitespace:diff -w file1.txt file2.txt
This option is useful for comparing code where indentation or spacing may vary.
-
-b
(Ignore Changes in Whitespace Quantity): Ignores changes in the amount of whitespace:diff -b file1.txt file2.txt
This is useful for ignoring differences in indentation but still recognizing differences in words.
-
-u
(Unified Diff Format): Creates a unified diff, which is a more readable and compact format commonly used for patches:diff -u file1.txt file2.txt
This option is particularly useful for generating patches that can be applied using the
patch
command. -
-r
(Recursive Comparison): Compares directories recursively:diff -r dir1 dir2
-
-q
(Report Only When Files Differ): Reports only when files differ, without showing the actual differences:diff -q file1.txt file2.txt
This option is useful for quickly checking if two files are different without displaying the details.
-
-s
(Report When Files Are The Same): Reports when files are the same:diff -s file1.txt file2.txt
This option is useful for verifying that files are identical after a copy or transfer.
-
-x
(Exclude Files): Excludes files matching a specified pattern:diff -r dir1 dir2 -x "*.o"
This command compares
dir1
anddir2
recursively, excluding files with the.o
extension. -
-X
(Exclude Files From File): Excludes files listed in a specified file:diff -r dir1 dir2 -X exclude_list.txt
This command compares
dir1
anddir2
recursively, excluding files listed inexclude_list.txt
.
By using these options, you can tailor the diff
command to suit your specific needs, whether you need to ignore certain types of differences, create patches, or compare directories recursively. For example, using -i
and -w
can help you focus on the semantic differences between files, ignoring irrelevant formatting changes. The -u
option is essential for creating patches that can be easily shared and applied to update files.
10. How Do You Create A Patch File Using diff
And Apply It?
You can create a patch file using the diff
command with the -u
(unified) option and apply it using the patch
command. Patch files are commonly used to distribute changes between different versions of a file or software.
-
Create a Patch File: Use the
diff
command with the-u
option to create a unified diff file:diff -u original_file.txt modified_file.txt > my_patch.patch
This command creates a patch file named
my_patch.patch
that contains the differences betweenoriginal_file.txt
andmodified_file.txt
. -
Apply a Patch File: Use the
patch
command to apply the patch to the original file:patch original_file.txt < my_patch.patch
This command applies the changes in
my_patch.patch
tooriginal_file.txt
, updating it to matchmodified_file.txt
. -
Reverse a Patch: If you need to undo the changes, you can use the
-R
option with thepatch
command:patch -R original_file.txt < my_patch.patch
This command reverses the changes in
my_patch.patch
, revertingoriginal_file.txt
to its original state. -
Apply a Patch with Original File in a Different Location: If the original file is in a different directory, you can use the
-p
option to specify the path depth to strip:patch -p1 < my_patch.patch
The
-p1
option tellspatch
to remove the first directory component from the file names in the patch file. This is useful when the patch file includes directory information that doesn’t match the current directory structure. -
Check If a Patch Can Be Applied: Before applying a patch, you can use the
--dry-run
option to check if the patch can be applied without actually making any changes:patch --dry-run original_file.txt < my_patch.patch
This command simulates the patching process and reports any errors or conflicts that would occur.
Creating and applying patch files is a fundamental part of software development and version control. Patch files allow you to share changes easily and efficiently, making it simple to update files and collaborate with others. The diff
and patch
commands are essential tools for managing and distributing changes in Unix environments. For example, patch files are commonly used to distribute bug fixes, security updates, and new features in open-source software projects.
11. How Can You Visually Compare Files In A Terminal?
You can visually compare files in a terminal using tools like vimdiff
, colordiff
, or meld
(if you have X server access). These tools highlight the differences between files, making it easier to spot discrepancies.
-
vimdiff
: Thevimdiff
tool is a visual diff utility within the Vim editor:vimdiff file1.txt file2.txt
This command opens Vim with
file1.txt
andfile2.txt
displayed side by side, highlighting the differences. You can navigate between the differences using the[c
and]c
commands. -
colordiff
: Thecolordiff
command is a wrapper around thediff
command that adds color to the output, making it easier to read:colordiff file1.txt file2.txt
If
colordiff
is not installed, you can typically install it using your system’s package manager (e.g.,apt-get install colordiff
on Debian/Ubuntu). -
meld
: Themeld
tool is a graphical diff and merge tool that can be used from the command line if you have X server access:meld file1.txt file2.txt
This command opens a graphical window with
file1.txt
andfile2.txt
displayed side by side, highlighting the differences. -
Using
less
with ANSI escape codes: You can use thediff
command to generate ANSI escape codes that highlight the differences, and then pipe the output toless
with the-r
option to display the colors:diff --color=always file1.txt file2.txt | less -r
This command requires a
diff
version that supports the--color=always
option.
These tools provide different ways to visualize file differences in the terminal. The vimdiff
tool is useful for detailed comparisons and editing, while colordiff
provides a simple way to add color to the standard diff
output. The meld
tool offers a more advanced graphical interface for comparing and merging files.
12. How Do You Compare Files On Remote Servers?
Comparing files on remote servers can be achieved using tools like ssh
, scp
, rsync
, or by mounting remote filesystems using sshfs
. These methods allow you to access and compare files located on different servers as if they were local.
-
Using
ssh
anddiff
: You can usessh
to execute thediff
command on a remote server and compare files directly:ssh user@remote_server "diff file1.txt file2.txt"
This command executes
diff file1.txt file2.txt
onremote_server
asuser
and displays the output locally. -
Using
scp
anddiff
: You can usescp
to copy files from a remote server to your local machine and then usediff
to compare them:scp user@remote_server:file1.txt . scp user@remote_server:file2.txt . diff file1.txt file2.txt
This command copies
file1.txt
andfile2.txt
fromremote_server
to the current directory and then compares them locally. -
Using
rsync
: Thersync
command can be used to compare files on remote servers efficiently:rsync -nv user@remote_server:file1.txt file2.txt
This command compares
file1.txt
onremote_server
withfile2.txt
locally and shows the differences without transferring any data. The-n
option (dry-run) prevents actual data transfer. -
Using
sshfs
: Thesshfs
command allows you to mount a remote directory as a local filesystem, making it easy to access and compare files:sshfs user@remote_server:/remote/directory /local/mountpoint diff /local/mountpoint/file1.txt /local/mountpoint/file2.txt fusermount -u /local/mountpoint
This command mounts the
/remote/directory
onremote_server
to/local/mountpoint
locally, allowing you to use local tools likediff
to compare files. Thefusermount -u
command unmounts the filesystem. -
Using
vimdiff
withscp
: You can combinevimdiff
withscp
to visually compare files on remote servers:vimdiff <(ssh user@remote_server "cat file1.txt") <(cat file2.txt)
These methods provide different ways to compare files on remote servers, allowing you to choose the one that best suits your needs. The ssh
and scp
commands are useful for simple comparisons, while rsync
is more efficient for synchronizing files. The sshfs
command provides a seamless way to access remote files as if they were local, making it easy to use local tools for comparison.
13. How Do You Automate File Comparisons In Unix Scripts?
You can automate file comparisons in Unix scripts by using commands like diff
, cmp
, or grep
along with conditional statements to handle different outcomes. This allows you to create scripts that automatically check for file differences and take appropriate actions.
-
Using
diff
: You can use thediff
command in a script to check for differences between two files and take action based on the result:#!/bin/bash file1="file1.txt" file2="file2.txt" diff "$file1" "$file2" > /dev/null if [ $? -ne 0 ]; then echo "Files are different" # Add actions to take when files are different else echo "Files are identical" # Add actions to take when files are identical fi
In this script, the
diff
command comparesfile1.txt
andfile2.txt
. The output is redirected to/dev/null
to suppress it. The$?
variable contains the exit status of the last command. If the exit status is not 0, it means the files are different. -
Using
cmp
: Thecmp
command can be used to quickly check if two files are identical:#!/bin/bash file1="file1.txt" file2="file2.txt" cmp -s "$file1" "$file2" if [ $? -eq 0 ]; then echo "Files are identical" # Add actions to take when files are identical else echo "Files are different" # Add actions to take when files are different fi
The
-s
option suppresses the output of thecmp
command. If the exit status is 0, it means the files are identical. -
Using
grep
: Thegrep
command can be used to find lines in one file that are not in another:#!/bin/bash file1="file1.txt" file2="file2.txt" missing_lines=$(grep -v -f "$file2" "$file1") if [ -n "$missing_lines" ]; then echo "The following lines are in file1 but not in file2:" echo "$missing_lines" # Add actions to take when lines are missing else echo "All lines in file1 are also in file2" # Add actions to take when all lines are present fi
This script uses
grep
to find lines infile1.txt
that are not infile2.txt
. The-v
option inverts the match, and the-f
option specifies the file containing the patterns. The script checks if the$missing_lines
variable is not empty to determine if there are any missing lines. -
Using
rsync
: Thersync
command can be used to synchronize files and directories:#!/bin/bash dir1="/path/to/dir1" dir2="/path/to/dir2" rsync -n -q -r "$dir1/" "$dir2/" | while read line; do echo "$line" # Add actions to take for each difference done
These examples illustrate how to automate file comparisons in Unix scripts. By combining these commands with conditional statements, you can create scripts that automatically check for file differences and take appropriate actions based on the results. For example, you can create a script that automatically updates configuration files, synchronizes directories, or alerts you to any unexpected changes in important files.
14. What Are Common Errors When Comparing Files And How To Fix Them?
Common errors when comparing files include incorrect command syntax, missing options, comparing unsorted files with comm
, and overlooking case sensitivity. Understanding these errors and their solutions can help you troubleshoot file comparison issues effectively.
-
Incorrect Command Syntax: Ensure that you are using the correct syntax for the command and options. Refer to the command’s manual page for the correct usage:
man diff man cmp man grep
-
Missing Options: Make sure you are using the appropriate options for your specific needs. For example, use the
-r
option withdiff
to compare directories recursively, and the-i
option to ignore case:diff -r dir1 dir2 diff -i file1.txt file2.txt
-
Comparing Unsorted Files with
comm
: Thecomm
command requires the input files to be sorted. If the files are not sorted, the output will be incorrect. Sort the files before usingcomm
:sort file1.txt > sorted_file1.txt sort file2.txt > sorted_file2.txt comm sorted_file1.txt sorted_file2.txt
-
Overlooking Case Sensitivity: Remember that Unix commands are case-sensitive. If you want to ignore case, use the
-i
option with commands likediff
andgrep
:diff -i file1.txt file2.txt grep -i "pattern" file.txt
-
Incorrect File Paths: Double-check that you are using the correct file paths in your commands. Relative paths are relative to your current working directory, while absolute paths start with
/
:diff /path/to/file1.txt /path/to/file2.txt
-
Permissions Issues: Ensure that you have the necessary permissions to read the files you are trying to compare. If you do not have read permissions, you will get an error:
chmod +r file.txt
-
Whitespace Differences: Be aware that whitespace differences can affect the comparison results. Use the
-w
or-b
options withdiff
to ignore whitespace:diff -w file1.txt file2.txt diff -b file1.txt file2.txt
-
Line Endings: Different operating systems use different line endings (e.g., LF in Unix, CRLF in Windows). This can cause files to be reported as different even if they are otherwise identical. Use the
dos2unix
orunix2dos
commands to convert line endings:dos2unix file.txt unix2dos file.txt
*Using the wrong diff format**: The diff command outputs a diff in multiple formats. If you are having problems applying a patch, check the diff format and specify it using –[context/ed/normal/unifed].
By addressing these common errors, you can ensure that your file comparisons are accurate and reliable. Always double-check your command syntax, options, file paths, and permissions, and be aware of potential issues related to case sensitivity, whitespace, and line endings.
15. How Can You Verify The Integrity Of Files After Transfer?
You can verify the integrity of files after transfer using checksums such as MD5, SHA-1, or SHA-256. These algorithms generate a unique hash value for a file, which can be compared before and after the transfer to ensure that the file has not been corrupted.
-
Using
md5sum
: Themd5sum
command calculates the MD5 checksum of a file:md5sum file.txt
This command will output the MD5 checksum and the filename. You can save the checksum to a file and then compare it after the transfer.
-
Using
sha1sum
: Thesha1sum
command calculates the SHA-1 checksum of a file:sha1sum file.txt
SHA-1 is more secure than MD5 but is also more computationally expensive.
-
Using
sha256sum
: Thesha256sum
command calculates the SHA-256 checksum of a file:sha256sum file.txt
SHA-256 is the most secure of the three algorithms and is recommended for critical file transfers.
-
Verifying File Integrity: To verify the integrity of a file after transfer, calculate the checksum of the original file and the transferred file, and then compare the checksums:
# On the source machine sha256sum file.txt > file.txt.sha256 # Transfer both file.txt and file.txt.sha256 to the destination machine # On the destination machine sha256sum -c file.txt.sha256
The
sha256sum -c
command checks the SHA-256 checksum offile.txt
against the value stored infile.txt.sha256
. If the checksums match, the command will output “file.txt: OK”. If they do not match, it will output “file.txt: FAILED”. -
Using
rsync
for Automatic Checksum Verification: Thersync
command can automatically verify file integrity