LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 10-13-2015, 08:13 AM   #1
Upendra Pratap Singh
Member
 
Registered: May 2011
Location: India
Distribution: Ubuntu 14.04
Posts: 110
Blog Entries: 4

Rep: Reputation: 0
get the list of files present in both the folders


Hi,

I want the list of those files which are in folder1 and also in folder2.

Can you guys help me with this?
 
Old 10-13-2015, 08:34 AM   #2
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fedora-35
Posts: 5,313

Rep: Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918
man ls ?
 
Old 10-13-2015, 01:10 PM   #3
Habitual
LQ Veteran
 
Registered: Jan 2011
Location: Abingdon, VA
Distribution: Catalina
Posts: 9,374
Blog Entries: 37

Rep: Reputation: Disabled
Show us your work so far please.
 
Old 10-15-2015, 08:34 AM   #4
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,634

Rep: Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965
Quote:
Originally Posted by Upendra Pratap Singh View Post
Hi,
I want the list of those files which are in folder1 and also in folder2. Can you guys help me with this?
We can certainly help...as soon as you post the script you've written, and tell us where you're stuck. Since you've been here for FOUR YEARS now, you should be well familiar with the man pages, and the basics of Linux commands and scripting.
 
1 members found this post helpful.
Old 10-15-2015, 09:56 AM   #5
r0tty
Member
 
Registered: May 2011
Posts: 33

Rep: Reputation: 1
Hi,

This?

# ls -1 folder1 folder2 | rev | cut -d "/" -f 1 | rev | sort | uniq -d

Unless you want to know that the files are identical as well as sharing the same name when it would be something more like this:

# md5sum folder1/* folder2/* | sed "s/ .*\// /" | sort | uniq -d | cut -d " " -f 2 | sort

I'm sure there are more beautiful ways to do it, but this should get you going?

Rotty
 
Old 10-15-2015, 04:53 PM   #6
Habitual
LQ Veteran
 
Registered: Jan 2011
Location: Abingdon, VA
Distribution: Catalina
Posts: 9,374
Blog Entries: 37

Rep: Reputation: Disabled
Code:
diff -q folder1 folder2 --suppress-common-lines
and if you want sub-directories included:
Code:
diff -q folder1 folder2 --suppress-common-lines -r
see
Code:
diff --help
for further switches such as Case-Sensitivity
el al.
 
1 members found this post helpful.
  


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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] tar only files/dirs present in the list - not any others paziulek Linux - General 5 05-24-2012 01:39 PM
[SOLVED] How to list folder size, and number of files and folders in folder steven.c.banks Linux - General 3 11-24-2010 06:24 AM
Help needed to transfer list of files to FTP server, to different folders amazon Programming 1 06-26-2009 01:12 AM
[CentOS] Folders+Files Users Access Control List Remoz Linux - Server 1 02-24-2009 05:23 AM
how to create a list of files and folders (name and size only) rastiazul Linux - General 16 11-04-2008 03:14 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 01:13 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