Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

linux diff to only output filename and nothing else

Tags:

linux

diff

I'm trying to get diff to output only the name of the modified files. I tried to use the -q option but it's still giving me too much output :

What i get now is this :

files path/to/file1/file1 and path/to/file2/file2 are different

And i would like this :

path/to/file1/file1

Any ideas on how to do this ?

like image 900
titiyoyo Avatar asked Dec 30 '25 20:12

titiyoyo


2 Answers

Use the exit status of diff:

if ! diff -q file1 file2 >/dev/null; then echo file1; fi
like image 95
Karoly Horvath Avatar answered Jan 01 '26 10:01

Karoly Horvath


You could do: diff -q file1 file2 | cut -f2 -d' '

like image 27
mikhail Avatar answered Jan 01 '26 11:01

mikhail



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!