Sponsored Content
Top Forums UNIX for Beginners Questions & Answers Compare two directory and find differents Post 303045791 by indeed_1 on Monday 13th of April 2020 02:11:46 PM
Old 04-13-2020
Compare two directory and find differents

Hi have two directory with below name in “/opt“

1-Source
2-Destination

In “Source”¯ directory there is a lot's of files, with extensions (doc, docx , ppt, xls,...).
In “Destination”¯ directory only pdf version of (doc, docx) files that exist in source stored.

Now I want to create script that use “diff”¯ command check “source”¯ and get list of only (doc, docx) files after that look for related pdf file in “Destination”¯ if pdf version of (doc, docx) not exist in “destination”¯ store list of them on a file.

E.g.

1-Source
Code:
File1.doc
File2.docx
File3.doc
File4.ppt
File5.xls
File6.doc

2-Destination
Code:
File1.pdf
File3.pdf

Expected result after run script is:
Code:
File2.docx
File6.doc

Here is my script
Code:
diff -r “/opt/source”¯ “/opt/destination“


Any recommendation?
Thanks



UPDATE
Follow below post and work like charm:

Code:
comm -23 <(find dir1 -type f -exec bash -c 'basename "${0%.*}"' {} \; | sort) <(find dir2 -type f -exec bash -c 'basename "${0%.*}"' {} \; | sort)
test1

filenames - diff two directories, but ignore the extensions - Unix & Linux Stack Exchange

Last edited by indeed_1; 04-14-2020 at 08:04 AM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Directory compare script

Hello, I am looking for a script, or pointer to an approach to creating a script, that will compare two versions of a codebase and output a third directory structure containing only the files that differ between the two. I use diff quite often, but it will only create patch files (AFAIK). Does... (3 Replies)
Discussion started by: jwilliams108
3 Replies

2. Shell Programming and Scripting

Script That Can navigate to 3 differents directory & remove files under them

Hi I am Trying to Write a script that can goto 4 different directorys on the server & remove the Files older then 30 days ?? /logs logs1 logs2 logs3 Now I need to remove files under logs1 logs2 logs3 which are older then 30 days whose name stat 'sit' , 'mig','bld' . in... (3 Replies)
Discussion started by: Beginner123
3 Replies

3. Shell Programming and Scripting

How i can obtain differents data on a single pass?

#!/bin/bash for i in `ls -c1 /usr/share/applications` do #name=`cat /usr/share/applications/$i | grep ^Name= | cut -d = -f2` #categories=`cat /usr/share/applications/$i | grep ^Categories= | sed 's/;/=/g' | cut -d = -f2` name=$(grep ^Name= /usr/share/applications/$i | cut -d = -f2)... (12 Replies)
Discussion started by: alexscript
12 Replies

4. Shell Programming and Scripting

Compare new version of two directory

How to compare new version exist of two path directory. for e.g., path1 - /user/path/test/ path2 - /user/path/score/ If its exist new version then copy that new version into the first path directroy. How will do this. (3 Replies)
Discussion started by: roy1912
3 Replies

5. Shell Programming and Scripting

Extract sequences of bytes from binary for differents blocks

Hello to all, I would like to search sequences of bytes inside big binary file. The bin file contains blocks of information, each block begins is estructured as follow: 1- Each block begins with the hex 32 (1 byte) and ends with FF. After the FF of the last block, it follows 33. 2- Next... (59 Replies)
Discussion started by: Ophiuchus
59 Replies

6. Shell Programming and Scripting

Find every directory named XYZ under the DVLP directory

I only want to find files under each branch of the directory tree inside directories named XYZ and there are multiple XYZ directories? (7 Replies)
Discussion started by: emc^24sho
7 Replies

7. Programming

Query SQL get two values differents from the same columns

Hi, I have 2 different values in the same column and two different values in other column Query 1 ins name value 1 Test 12345 1 TestV1 12/10/2014 8 Test 85435 8 TestV1 11/11/2005 9 Test 42232 9 TestV1 19/10/2000 6 Test 54321... (6 Replies)
Discussion started by: faka
6 Replies

8. Shell Programming and Scripting

awk - matching on 2 columns for differents lines

Given this file (I separated them in block to make my explanation clearer): 92157768877;Sof_deme_Fort_Email_am_%yyyy%%mm%%dd%;EMAIL;20/02/2015;1;0;0 92157768877;Sof_trav_Fort_Email_am_%yyyy%%mm%%dd%;EMAIL;20/02/2015;1;0;0 91231838895;Sof_deme_faible_Email_am;EMAIL;26/01/2015;1 0;0... (1 Reply)
Discussion started by: Andy_K
1 Replies

9. Shell Programming and Scripting

Compare directory dates

hi, I need to know if a specific directory exists in a folder named after the date of yesterday (02/06/2015) The problem is simple but not how to do it. :confused:i= date -d "yesterday" '%Y-%m-%d' <- the format of directory is 2015-06-02 if in /var/logroot/index exist directory whit... (4 Replies)
Discussion started by: tmeto
4 Replies

10. UNIX for Beginners Questions & Answers

How to find and get a file in an entire directory with an excluded directory specified?

How to get a file 'zlib.h' in an entire directory with an excluded directory specified lives under that starting directory by using find command, as it failed on: $ find . -name 'zlib.h' -a -ipath 'CHROME.TMP' -prune -o -print it'll just list entirely up (2 Replies)
Discussion started by: abdulbadii
2 Replies
DH_INSTALLDOCS(1)						     Debhelper							 DH_INSTALLDOCS(1)

NAME
dh_installdocs - install documentation into package build directories SYNOPSIS
dh_installdocs [debhelperoptions] [-A] [-Xitem] [file...] DESCRIPTION
dh_installdocs is a debhelper program that is responsible for installing documentation into usr/share/doc/package in package build directories. FILES
debian/package.docs List documentation files to be installed into package. debian/copyright The copyright file is installed into all packages, unless a more specific copyright file is available. debian/package.copyright debian/package.README.Debian debian/package.TODO Each of these files is automatically installed if present for a package. debian/README.Debian debian/TODO These files are installed into the first binary package listed in debian/control. Note that README.debian files are also installed as README.Debian, and TODO files will be installed as TODO.Debian in non-native packages. debian/package.doc-base Installed as doc-base control files. Note that the doc-id will be determined from the Document: entry in the doc-base control file in question. debian/package.doc-base.* If your package needs to register more than one document, you need multiple doc-base files, and can name them like this. OPTIONS
-A, --all Install all files specified by command line parameters in ALL packages acted on. -Xitem, --exclude=item Exclude files that contain item anywhere in their filename from being installed. Note that this includes doc-base files. --link-doc=package Make the documentation directory of all packages acted on be a symlink to the documentation directory of package. This has no effect when acting on package itself, or if the documentation directory to be created already exists when dh_installdocs is run. To comply with policy, package must be a binary package that comes from the same source package. debhelper will try to avoid installing files into linked documentation directories that would cause conflicts with the linked package. The -A option will have no effect on packages with linked documentation directories, and copyright, changelog, README.Debian, and TODO files will not be installed. (An older method to accomplish the same thing, which is still supported, is to make the documentation directory of a package be a dangling symlink, before calling dh_installdocs.) file ... Install these files as documentation into the first package acted on. (Or in all packages if -A is specified). EXAMPLES
This is an example of a debian/package.docs file: README TODO debian/notes-for-maintainers.txt docs/manual.txt docs/manual.pdf docs/manual-html/ NOTES
Note that dh_installdocs will happily copy entire directory hierarchies if you ask it to (similar to cp -a). If it is asked to install a directory, it will install the complete contents of the directory. Note that this command is not idempotent. dh_prep(1) should be called between invocations of this command. Otherwise, it may cause multiple instances of the same text to be added to maintainer scripts. SEE ALSO
debhelper(7) This program is a part of debhelper. AUTHOR
Joey Hess <joeyh@debian.org> 8.9.0ubuntu2.1 2012-06-12 DH_INSTALLDOCS(1)
All times are GMT -4. The time now is 11:23 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy