Hello Guys,
I request anyone to do me a small help in using diff command for following.
I am trying to compare two files for content and wish to keep the content after the comparison (The resultant file can't be blank)
However, the first lines would be different in both files and I need diff command to ignore these first lines in both files.
For e.g -
File 1 -
Abcd
test1
test2
test3
File 2 -
Abcfdfd
test1
test2
test3
Now, I am trying to use
diff -ty -B -I "^Abc" file1 file2 > file3
Here, I am trying to use a ignore flag for diff to ignore lines in both files that start with "Abc" however, I keep getting syntax errors for diff saying - Try diff --help for more information.
Can someone please tell me how do I make the above happen? Any help is greatly appreciated -
Cheers,
Morgan
It works fine in my GNU diff in Cygwin:
$
$
$ cat file1
Abcd
test1
test2
test3
$
$ cat file2
Abcfdfd
test1
test2
test4
$
$
$ diff -ty -B file1 file2
Abcd | Abcfdfd
test1 test1
test2 test2
test3 | test4
$
$
$ diff -ty -B -I "^Abc" file1 file2
Abcd Abcfdfd
test1 test1
test2 test2
test3 | test4
$
$ diff --version
diff (GNU diffutils) 2.9
Copyright (C) 2010 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Written by Paul Eggert, Mike Haertel, David Hayes,
Richard Stallman, and Len Tower.
$
$
Maybe your diff or system is different?
tyler_durden
I have a diff version as 2.8.1 and OS is RHEL 5.2
Am checking further and would let you know shortly.
Thanks,
Morgan