Sponsored Content
Full Discussion: comparing 2 files
Top Forums UNIX for Dummies Questions & Answers comparing 2 files Post 302352021 by radoulov on Thursday 10th of September 2009 08:27:04 AM
Old 09-10-2009
Code:
diff -b a.txt b.txt

For more info:

Code:
man diff | less -p-b

 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

comparing shadow files with real files

Hi I need to compare shadow file sizes with their real file counterparts. If the shadow file size differs form the realfile size then it must send a mail. My problem is that our system has over 1600 shadowfiles in different directories, with different names. the only consistancy is the .sh file... (4 Replies)
Discussion started by: terrym
4 Replies

2. Shell Programming and Scripting

Comparing files

I have a file called X, which contains the following: 10 100 200 300 I then have file Y, which containts the following: 10 200 500 800 I want to write a script that will compare the contents of Y with the contents of X and ONLY return values in Y that does not exist in X (output... (5 Replies)
Discussion started by: soliberus
5 Replies

3. Shell Programming and Scripting

Need Help Comparing two Files

I really need help on creating a script that does the following: I have one file (File 1) with lines in the following format: Name.maf score1 score2 I have a second file (File 2) with lines in the following format: label start end Name What I need to do is compare File 1 and... (1 Reply)
Discussion started by: awknerd
1 Replies

4. Shell Programming and Scripting

Need help comparing two files and deleting some things in those files!

So I have two files: File1 pictures.txt 1.1 1.3 dance.txt 1.2 1.4 treehouse.txt 1.3 1.5 File2 pictures.txt 1.5 ref2313 1.4 ref2345 1.3 ref5432 1.2 ref4244 dance.txt 1.6 ref2342 1.5 ref2352 1.4 ref0695 1.3 ref5738 1.2 ref4948 1.1 treehouse.txt 1.6 ref8573 1.5 ref3284 1.4 ref5838... (24 Replies)
Discussion started by: linuxkid
24 Replies

5. Shell Programming and Scripting

Comparing the matches in two files using awk when both files have their own field separators

I've two files with data like below: file1.txt: AAA,Apples,123 BBB,Bananas,124 CCC,Carrot,125 file2.txt: Store1|AAA|123|11 Store2|BBB|124|23 Store3|CCC|125|57 Store4|DDD|126|38 So,the field separator in file1.txt is a comma and in file2.txt,it is | Now,the output should be... (2 Replies)
Discussion started by: asyed
2 Replies

6. UNIX for Advanced & Expert Users

How to find duplicates contents in a files by comparing other files?

Hi Guys , we have one directory ...in that directory all files will be set on each day.. files must have header ,contents ,footer.. i wants to compare the header,contents,footer ..if its same means display an error message as 'files contents same' (7 Replies)
Discussion started by: Venkatesh1
7 Replies

7. Shell Programming and Scripting

Help with comparing two files

Hi all I have to compare two file this time one is P11223 x1124 x1145 t5678 e3456 z2345 another file P11223 x s (2 Replies)
Discussion started by: manigrover
2 Replies

8. Shell Programming and Scripting

Comparing the files

Hi Friends, I have file1.txt file2.txt I tried using the diff and comm but not getting the expected output.. I want where exactly the miss match occurs. probably the field. Sourcevalue|Targetvalue|Linenumber|field 29123975|2923975|3|1 Please help. (6 Replies)
Discussion started by: i150371485
6 Replies

9. Shell Programming and Scripting

Comparing files in a directory against an array of files

I hope I can explain this correctly. I am using Bash-4.2 for my shell. I have a group of file names held in an array. I want to compare the names in this array against the names of files currently present in a directory. If the file does not exist in the directory, that is not a problem.... (5 Replies)
Discussion started by: BudMan
5 Replies

10. UNIX for Beginners Questions & Answers

Comparing two files and list the difference with common first line content of both files

I have two file as given below which shows the ACL permissions of each file. I need to compare the source file with target file and list down the difference as specified below in required output. Can someone help me on this ? Source File ************* # file: /local/test_1 # owner: own #... (4 Replies)
Discussion started by: sarathy_a35
4 Replies
DIFF(1) 							     GNU Tools								   DIFF(1)

NAME
diff - find differences between two files SYNOPSIS
diff [options] from-file to-file DESCRIPTION
In the simplest case, diff compares the contents of the two files from-file and to-file. A file name of - stands for text read from the standard input. As a special case, diff - - compares a copy of standard input to itself. If from-file is a directory and to-file is not, diff compares the file in from-file whose file name is that of to-file, and vice versa. The non-directory file must not be -. If both from-file and to-file are directories, diff compares corresponding files in both directories, in alphabetical order; this compari- son is not recursive unless the -r or --recursive option is given. diff never compares the actual contents of a directory as if it were a file. The file that is fully specified may not be standard input, because standard input is nameless and the notion of ``file with the same name'' does not apply. diff options begin with -, so normally from-file and to-file may not begin with -. However, -- as an argument by itself treats the remain- ing arguments as file names even if they begin with -. Options Below is a summary of all of the options that GNU diff accepts. Most options have two equivalent names, one of which is a single letter preceded by -, and the other of which is a long name preceded by --. Multiple single letter options (unless they take an argument) can be combined into a single command line word: -ac is equivalent to -a -c. Long named options can be abbreviated to any unique prefix of their name. Brackets ([ and ]) indicate that an option takes an optional argument. -lines Show lines (an integer) lines of context. This option does not specify an output format by itself; it has no effect unless it is combined with -c or -u. This option is obsolete. For proper operation, patch typically needs at least two lines of context. -a Treat all files as text and compare them line-by-line, even if they do not seem to be text. -b Ignore changes in amount of white space. -B Ignore changes that just insert or delete blank lines. --brief Report only whether the files differ, not the details of the differences. -c Use the context output format. -C lines --context[=lines] Use the context output format, showing lines (an integer) lines of context, or three if lines is not given. For proper operation, patch typically needs at least two lines of context. --changed-group-format=format Use format to output a line group containing differing lines from both files in if-then-else format. -d Change the algorithm to perhaps find a smaller set of changes. This makes diff slower (sometimes much slower). -D name Make merged if-then-else format output, conditional on the preprocessor macro name. -e --ed Make output that is a valid ed script. --exclude=pattern When comparing directories, ignore files and subdirectories whose basenames match pattern. --exclude-from=file When comparing directories, ignore files and subdirectories whose basenames match any pattern contained in file. --expand-tabs Expand tabs to spaces in the output, to preserve the alignment of tabs in the input files. -f Make output that looks vaguely like an ed script but has changes in the order they appear in the file. -F regexp In context and unified format, for each hunk of differences, show some of the last preceding line that matches regexp. --forward-ed Make output that looks vaguely like an ed script but has changes in the order they appear in the file. -h This option currently has no effect; it is present for Unix compatibility. -H Use heuristics to speed handling of large files that have numerous scattered small changes. --horizon-lines=lines Do not discard the last lines lines of the common prefix and the first lines lines of the common suffix. -i Ignore changes in case; consider upper- and lower-case letters equivalent. -I regexp Ignore changes that just insert or delete lines that match regexp. --ifdef=name Make merged if-then-else format output, conditional on the preprocessor macro name. --ignore-all-space Ignore white space when comparing lines. --ignore-blank-lines Ignore changes that just insert or delete blank lines. --ignore-case Ignore changes in case; consider upper- and lower-case to be the same. --ignore-matching-lines=regexp Ignore changes that just insert or delete lines that match regexp. --ignore-space-change Ignore changes in amount of white space. --initial-tab Output a tab rather than a space before the text of a line in normal or context format. This causes the alignment of tabs in the line to look normal. -l Pass the output through pr to paginate it. -L label --label=label Use label instead of the file name in the context format and unified format headers. --left-column Print only the left column of two common lines in side by side format. --line-format=format Use format to output all input lines in in-then-else format. --minimal Change the algorithm to perhaps find a smaller set of changes. This makes diff slower (sometimes much slower). -n Output RCS-format diffs; like -f except that each command specifies the number of lines affected. -N --new-file In directory comparison, if a file is found in only one directory, treat it as present but empty in the other directory. --new-group-format=format Use format to output a group of lines taken from just the second file in if-then-else format. --new-line-format=format Use format to output a line taken from just the second file in if-then-else format. --old-group-format=format Use format to output a group of lines taken from just the first file in if-then-else format. --old-line-format=format Use format to output a line taken from just the first file in if-then-else format. -p Show which C function each change is in. -P When comparing directories, if a file appears only in the second directory of the two, treat it as present but empty in the other. --paginate Pass the output through pr to paginate it. -q Report only whether the files differ, not the details of the differences. -r When comparing directories, recursively compare any subdirectories found. --rcs Output RCS-format diffs; like -f except that each command specifies the number of lines affected. --recursive When comparing directories, recursively compare any subdirectories found. --report-identical-files -s Report when two files are the same. -S file When comparing directories, start with the file file. This is used for resuming an aborted comparison. --from-file=file Compare file to all operands. file can be a directory. --to-file=file Compare all operands to file. file can be a directory. --sdiff-merge-assist Print extra information to help sdiff. sdiff uses this option when it runs diff. This option is not intended for users to use directly. --show-c-function Show which C function each change is in. --show-function-line=regexp In context and unified format, for each hunk of differences, show some of the last preceding line that matches regexp. --side-by-side Use the side by side output format. --speed-large-files Use heuristics to speed handling of large files that have numerous scattered small changes. --starting-file=file When comparing directories, start with the file file. This is used for resuming an aborted comparison. --suppress-common-lines Do not print common lines in side by side format. -t Expand tabs to spaces in the output, to preserve the alignment of tabs in the input files. -T Output a tab rather than a space before the text of a line in normal or context format. This causes the alignment of tabs in the line to look normal. --text Treat all files as text and compare them line-by-line, even if they do not appear to be text. -u Use the unified output format. --unchanged-group-format=format Use format to output a group of common lines taken from both files in if-then-else format. --unchanged-line-format=format Use format to output a line common to both files in if-then-else format. --unidirectional-new-file When comparing directories, if a file appears only in the second directory of the two, treat it as present but empty in the other. -U lines --unified[=lines] Use the unified output format, showing lines (an integer) lines of context, or three if lines is not given. For proper operation, patch typically needs at least two lines of context. -v --version Output the version number of diff. -w Ignore white space when comparing lines. -W columns --width=columns Use an output width of columns in side by side format. -x pattern When comparing directories, ignore files and subdirectories whose basenames match pattern. -X file When comparing directories, ignore files and subdirectories whose basenames match any pattern contained in file. -y Use the side by side output format. SEE ALSO
cmp(1), comm(1), diff3(1), ed(1), patch(1), pr(1), sdiff(1). DIAGNOSTICS
An exit status of 0 means no differences were found, 1 means some differences were found, and 2 means trouble. GNU Tools 22sep1993 DIFF(1)
All times are GMT -4. The time now is 06:55 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy