LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 02-26-2019, 06:45 PM   #1
catiewong
Member
 
Registered: Aug 2018
Posts: 190

Rep: Reputation: Disabled
how to compare two directory , the existing files are the same


I have two directory , I would like to compare the files in these file are exactly the same , compare everything includes the file is existing , the file creation date , the file permission etc. and output the difference

I know the command "find" would find the file structure but how to better use it to compare ?
 
Old 02-26-2019, 07:33 PM   #2
1nuxg33k
Member
 
Registered: Feb 2019
Location: PNW
Distribution: Debian, LFS
Posts: 87

Rep: Reputation: 33
uniq -u. This will print uniq lines from two files.
Code:
uniq -u File1 File2
As for the File creation date and permissions you would probably have to pipe the ls command to uniq or just compare the two files with ls and note the date and permissions.
 
Old 02-26-2019, 07:35 PM   #3
Ztcoracat
LQ Guru
 
Registered: Dec 2011
Distribution: Slackware, MX 18
Posts: 9,484
Blog Entries: 15

Rep: Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176
Hi:

If all you want to do is compare files use the diff command:-

Code:
diff file1 file2

Different ways to use the diff cmd.
https://www.lifewire.com/compare-two...-linux-3861434
 
Old 02-26-2019, 07:49 PM   #4
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,149

Rep: Reputation: 4124Reputation: 4124Reputation: 4124Reputation: 4124Reputation: 4124Reputation: 4124Reputation: 4124Reputation: 4124Reputation: 4124Reputation: 4124Reputation: 4124
A simple search for "duplicate file linux" will give you several options. Do basic research yourself.
 
1 members found this post helpful.
Old 02-26-2019, 08:28 PM   #5
catiewong
Member
 
Registered: Aug 2018
Posts: 190

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by 1nuxg33k View Post
uniq -u. This will print uniq lines from two files.
Code:
uniq -u File1 File2
As for the File creation date and permissions you would probably have to pipe the ls command to uniq or just compare the two files with ls and note the date and permissions.
sorry , may be I rephrase my question , what I want is to find the difference of two directories , not only two files .

thanks
 
Old 02-26-2019, 08:37 PM   #6
scasey
LQ Veteran
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.9.2009
Posts: 5,738

Rep: Reputation: 2222Reputation: 2222Reputation: 2222Reputation: 2222Reputation: 2222Reputation: 2222Reputation: 2222Reputation: 2222Reputation: 2222Reputation: 2222Reputation: 2222
Quote:
Originally Posted by catiewong View Post
I have two directory , I would like to compare the files in these file are exactly the same , compare everything includes the file is existing , the file creation date , the file permission etc. and output the difference

I know the command "find" would find the file structure but how to better use it to compare ?
Capture a long directory listing for each directory into separate files.
Use diff to compare the files. '

man ls for the long listing
man diff
 
Old 02-27-2019, 03:12 PM   #7
Ztcoracat
LQ Guru
 
Registered: Dec 2011
Distribution: Slackware, MX 18
Posts: 9,484
Blog Entries: 15

Rep: Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176
Quote:
Originally Posted by catiewong View Post
sorry , may be I rephrase my question , what I want is to find the difference of two directories , not only two files .

thanks
This was an easy Google search:-

How to Find Difference Between Two Directories Using Diff and Meld Tools
https://www.tecmint.com/compare-find...ries-in-linux/
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
how to compare two directory , the files are the same catiewong Linux - Newbie 13 01-03-2019 05:51 AM
[SOLVED] How to compare a list of files in two directories: compare content and print size Batistuta_g_2000 Linux - Newbie 9 03-24-2013 07:05 AM
[SOLVED] cannot compare two directories, and print files that have same name and content apanimesh061 Fedora 3 09-17-2010 10:17 AM
compare two files and print the same text kariagekun Linux - Newbie 4 10-14-2009 07:24 AM
compare/diff two directory in two different linux/unix machine chuikingman Linux - Server 6 09-24-2009 08:09 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 12:50 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration