diff directories a and b. show only files in b, not in a

diff, unix

Solution

Try this

pick-up one of these :

$ LANG=C diff -qr a b | awk -F"Only in b: " '/^Only in b:/{print $2}'

or

$ LANG=C diff -qr a b | grep -oP "^Only in b: \K.*"

or

$ LANG=C diff -qr a b | grep '^Only in b:' | cut -d: -f2-

Note

LANG=C

is only there to avoid displaying in any locale language but in English.

Doc

See `man diff`

Problem

the title sumarises my question. given directories a and b, i want to be able to generate a list of files that are in b but not in a. a normal diff does this, but it also shows files in a not in b: ``` $ diff -u /mnt/Media/a ~/b Only in /mnt/Media/a: abab Only in /home/conor/b: blah ``` i would also like diff to list filenames only - none of the "Only in .." stuff thanks

Original source