Sponsored Content
Top Forums Shell Programming and Scripting Compare files with different names in different directories Post 302941757 by Don Cragun on Monday 20th of April 2015 09:31:44 PM
Old 04-20-2015
Quote:
Originally Posted by GosarJunk
Sorry for the late reply

Don,

Names of the files in various directories will be same except for the datetime appended at the end of the files. All the files will appear in all the directories. I can use the BASH shell or the basic shell or KSH. I am just trying to get a "Diff" from the similar files in different directories. Output will be similar to the "diff" command. The script i have curently is as shown in my original post - List of "diff" commands will actual files-names for all the files.
Code:
/usr/bin/diff Directory1/f1.txt.04012015 Directory2/f1.txt.04022015 
/usr/bin/diff Directory1/f2.txt.04012015 Directory2/f2.txt.04022015
...
...

In your first post in this thread, you said you had a shell script that produced a script of the diff commands you wanted to execute, and you showed us the 1st two lines of output from that script.

Show us that script; not its output! It will help us understand what your directory structure really looks like, what files need to be compared, what you want done if expected files are missing, ... ... ... Without seeing your working script, there are just too many details that you haven't specified to be able to be of much help; unless you just want us to waste our time trying to guess at your requirements.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Compare File Names in Different Directories...

I do not know much about shell scripting and need to create a script and I am at a loss. If someone can help me, that would be great!! I have two directories: /dir1 /dir2 I need to get the sequence number which is part of the filename in /dir1 and delete all files in /dir2 that are... (4 Replies)
Discussion started by: stky13
4 Replies

2. Shell Programming and Scripting

compare files in two directories and output changed files to third directory

I have searched about 30 threads, a load of Google pages and cannot find what I am looking for. I have some of the parts but not the whole. I cannot seem to get the puzzle fit together. I have three folders, two of which contain different versions of multiple files, dist/file1.php dist/file2.php... (4 Replies)
Discussion started by: bkeep
4 Replies

3. Shell Programming and Scripting

Compare list [ names and size files ]

Hello, I've downloaded a huge amont of files I've got a list of files from a remote server. -rw-r--r-- 1 str661 strem 453465260 Dec 16 15:54 SATRYS2V1_20021218_temp_bias.nc -rw-r--r-- 1 str661 strem 17669468 Dec 16 18:01 SATRYS2V1_20021225_hdyn_bias.nc -rw-r--r-- 1... (9 Replies)
Discussion started by: Aswex
9 Replies

4. UNIX for Dummies Questions & Answers

how to compare names of files?

hi, can somebody tell me how to compare names of files? the situation is I have 2 files file1 and file2 and I want to figure out which file has the biggest ending, in this case file2 is. thank you (3 Replies)
Discussion started by: s3270226
3 Replies

5. Shell Programming and Scripting

Check for particular files and compare the file names

Hi, Below are the 2 files in directory /tmp: masterCSF242323.img indexCSF242323.img 1) I want to compare if both the number (242323) are same in both the files. If they are same print - Files matching, else print files do not match. 2) Also if only index file is present in that... (7 Replies)
Discussion started by: apatil65
7 Replies

6. Shell Programming and Scripting

Extract function names and directories from php files

I need a script that extracts function names from php files together with their location (path and file in which they are defined). The php files are located in several directories under a base directory. Ideally the output should be something like: "Path/FileName/FunctionName" for a... (2 Replies)
Discussion started by: bamse
2 Replies

7. Shell Programming and Scripting

how to compare two files in different directories

Hi all , Can any one give me the solution for below query. I have two files . firstfile: xyz123 abc234 text2456 secondfile (\home\test) xyz123:ram ab34:scrit text2456:maven After you compare the ouput should the the common items in both files (2 Replies)
Discussion started by: sravan008
2 Replies

8. UNIX for Dummies Questions & Answers

Compare files in two directories

Hi All, I have two directories that has some files, some of the files are common to both of them like : ls -l dir1 file1 file2 file3 ls -l dir2 file1 file2 file3 file4 file5 Now i want to get the files from dir2 that are not present in dir1 (means i want to get... (2 Replies)
Discussion started by: mukulverma2408
2 Replies

9. Shell Programming and Scripting

Compare two files and get only missing names

I need to compare two files (oldfile1 & newfile). Need to ignore the values which are present in both files. At the same time, i need to get only records in new file. Tried using Join -v1 -v2 oldfile1 newfile (suspect it has not worked as expected). could anyone of you please help me here. (5 Replies)
Discussion started by: Selva_2507
5 Replies

10. Shell Programming and Scripting

Compare two files containing package names and version number

I have 2 files each containing a list of same fedora packages but with different version number. I want to compare the 2 files and remove the lines containing a newer or older version number (1 Reply)
Discussion started by: asya18
1 Replies
GENDIFF(1)						      General Commands Manual							GENDIFF(1)

NAME
gendiff - utility to aid in error-free diff file generation SYNOPSIS
gendiff <directory> <diff-extension> DESCRIPTION
gendiff is a rather simple script which aids in generating a diff file from a single directory. It takes a directory name and a "diff- extension" as its only arguments. The diff extension should be a unique sequence of characters added to the end of all original, unmodi- fied files. The output of the program is a diff file which may be applied with the patch program to recreate the changes. The usual sequence of events for creating a diff is to create two identical directories, make changes in one directory, and then use the diff utility to create a list of differences between the two. Using gendiff eliminates the need for the extra, original and unmodified directory copy. Instead, only the individual files that are modified need to be saved. Before editing a file, copy the file, appending the extension you have chosen to the filename. I.e. if you were going to edit somefile.cpp and have chosen the extension "fix", copy it to somefile.cpp.fix before editing it. Then edit the first copy (somefile.cpp). After editing all the files you need to edit in this fashion, enter the directory one level above where your source code resides, and then type $ gendiff somedirectory .fix > mydiff-fix.patch You should redirect the output to a file (as illustrated) unless you want to see the results on stdout. SEE ALSO
diff(1), patch(1) AUTHOR
Marc Ewing <marc@redhat.com> 4th Berkeley Distribution Mon Jan 10 2000 GENDIFF(1)
All times are GMT -4. The time now is 10:19 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy