Listing lines from just one file in DIFF
Solution 1:
Not sure diff
alone can do it but you can always use the power of other GNU utilities to help you.
diff -u diffa.txt diffb.txt | grep '^-[^-]' | sed 's/^-//'
It does the diff, then selects only the lines that begins with '-' - those are changed and have values from diffa.txt file, then sed
just remove those '-' signs.
Edit: After few experiments with diff
, looks like the below command produces what you want:
diff --changed-group-format='%<' --unchanged-group-format='' diffa.txt diffb.txt
Solution 2:
More simple method is to use comm
linux utility (It needs sorted file for input). It writes to standard output:
lines that are unique for diffa.txt
lines that are unique for diffb.txt
lines that are common
and you can suppress each one of them by parameter 1,2 or 3 accordingly. So in youre case it will look like this :
comm -23 diffa.txt diffb.txt
It suppresses lines that are unique for diffb.txt, lines that are common and prints out lines that are unique only for diffa.txt
Source from:https://www.tutorialspoint.com/unix_commands/comm.htm
Solution 3:
I'd like to mention that comm
expects sorted input files and thus reports different results than diff
.
diff --changed-group-format='%<' --unchanged-group-format='' diffa.txt diffb.txt
is universal. Kudos to @vava