Sponsored Content
Top Forums Shell Programming and Scripting Search and compare files from two paths Post 302786555 by DGPickett on Wednesday 27th of March 2013 05:35:04 PM
Old 03-27-2013
Seems like deja vu. Compare the file lists of the two directories, and the file content, using something like this:
Code:
diff -U0 <(
  cd head1
  find * -type f | sort | xargs -r cksum ) <(
  cd head2
  find * -type f | sort | xargs -r cksum ) | while read  diff_ind  cksum  sz  path
do
 case "$diff_ind" in
 (-)
  echo "Deleted file '$path'."
  ;;
 (+)
  echo "New file '$path':"
  cat head2/$path
  ;;
 (*)
  echo "Changed file '$path':"
  sdiff head1/$path head2/$path
  ;;
 esac
done

For stricter delete/new checking, use 'comm' not 'diff -U0' but no '| xargs -r cksum' until later, when you know both are present (no tab prefix is delete, one tab is new, two tabs is both). You can report new/delete on stderr and pipe others to stdout to cksum to another while read to compare cksums before running an sdiff.

Last edited by DGPickett; 03-27-2013 at 06:41 PM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to search & compare paragraphs between two files

Hello Guys, Greetings to All. I am stuck in my work here today while trying to comapre paragraphs between two files, I need your help on urgent basis, without your inputs I can not proceed. Kindly find some time to answer my question, I'll be grateful to you for ever. My detailed issue is as... (10 Replies)
Discussion started by: NARESH1302
10 Replies

2. UNIX Desktop Questions & Answers

how to display paths of files in a directory

hi guys does anyone know how to display the file paths of the files stored within a directory at the command terminal? e.g. if i have a directory called "home", how do i display the file paths of the files inside the directory? cheers (2 Replies)
Discussion started by: Villaman69
2 Replies

3. HP-UX

Search environment variables for paths

Hi, I am using the HP machine at the moment and by default I have been setup with the kron shell i.e. my home profile is .kshrc I would like to access a program anywhere on the system so I have added a path and created an environment variable like this: export myvarpath=/a/abc/def/ghij... (3 Replies)
Discussion started by: cyberfrog
3 Replies

4. Shell Programming and Scripting

compare two files and search keyword and print output

You have two files to compare by searching keyword from one file into another file File A 23 >pp_ANSWER 24 >aa hello 25 >jau head wear 66 >jss oops 872 >aqq olps ploww oww sss 722 >GG_KILLER ..... large files File B Beta done KILLER John Mayor calix meyers ... (5 Replies)
Discussion started by: cdfd123
5 Replies

5. Shell Programming and Scripting

Search compare and determine duplicate files

Hi May i ask if someone know a package that will search a directory recursively and compare determine duplicate files according to each filename, date modified or any attributes that will determine its duplicity If none where should i start or what are those command in shell scripting that... (11 Replies)
Discussion started by: jao_madn
11 Replies

6. UNIX for Dummies Questions & Answers

Determining file size for a list of files with paths

Hello, I have a flat file with a list of files with the path to the file and I am attempting to calculate the filesize for each one; however xargs isn't playing nicely and I am sure there is probably a better way of doing this. What I envisioned is this: cat filename|xargs -i ls -l {} |awk... (4 Replies)
Discussion started by: joe8mofo
4 Replies

7. Shell Programming and Scripting

Replace directory paths in multiple files at once

I need to update about 2400 files in a directory subtree, with a new directory path inside the files I need to change this occurence in all files: /d2/R12AB/VIS/apps/tech_st/10.1.2 with this: /u01/PROD/apps/apps_st/10.1.3 I know how to change single words using "find . -type f -print0 |... (6 Replies)
Discussion started by: wicus
6 Replies

8. UNIX Desktop Questions & Answers

Change name of files to their paths -- find loop

Dear All, I have many sub-folders but each of them have a file with same name but different data. I want to either move or copy them into a new folder but they need to have the path of where they are coming as part of their name... I have managed to find the files but dont know how to change... (2 Replies)
Discussion started by: A-V
2 Replies

9. UNIX for Dummies Questions & Answers

Search for string in a file then compare it with excel files entry

All, i have a file text.log: cover6 cover3 cover2 cover4 other file is abc.log as : 0 0 1 0 Then I have a excel file result.xls that contains: Name Path Pass cover2 cover3 cover6 cover4 (1 Reply)
Discussion started by: Anamika08
1 Replies

10. Shell Programming and Scripting

Script for linking files with paths in 2 text files

I have 2 txt files, 1.txt and 2.txt which contain the paths to files that need to be linked. Example 1.txt: /root/001/folder2/image4.nii.gz /root/002/folder2/image4.nii.gz Example 2.txt: /root/001/folder2/image5.nii.gz /root/002/folder2/image5.nii.gz Each line represents images from... (7 Replies)
Discussion started by: LeftoverStew
7 Replies
folders(1mh)															      folders(1mh)

Name
       folders - list folders and contents

Syntax
       folders [ +folder ] [ msg ] [ options ]

Description
       The command displays the names of your folders and the number of messages that they each contain.

       The  command displays a list of all the folders in your Mail directory.	The folders are sorted alphabetically, each on its own line.  This
       is illustrated in the following example:
	 Folder      # of messages (  range  ); cur  msg  (other files)
	   V2.3  has	3 messages (   1-   3).
	 adrian  has   20 messages (   1-  20); cur=   2.
	  brian  has   16 messages (   1-  16).
	  chris  has   12 messages (   1-  12).
	copylog  has  242 messages (   1- 242); cur= 225.
	  inbox+ has   73 messages (   1- 127); cur= 127.
	    int  has	4 messages (   1-   4); cur=   2  (others).
	   jack  has   17 messages (   1-  17); cur=  17.

		 TOTAL= 387 messages in 8 folders.
       The plus sign (+) after inbox indicates that it is the current folder.  The information about the folder includes the term (others).   This
       indicates  that the folder contains files which are not messages.  These files may be either sub-folders, or files that do not belong under
       the MH file naming scheme.

       The command is identical to the effect of using the -all option to the command.

       If you use with the +folder argument, it will display all the subfolders within the named folder.  as shown in the following example:
       % folders +test
       Folder		# of messages (  range	); cur	msg  (other files)
       test+ has	  18 messages (   1-  18);	     (others).
       test/testone has    1 message  (   1-   1).
       test/testtwo has   no messages.

	      TOTAL=   19 messages in 3 folders.
       See for more details of sub-folders.

Options
       -fast
       -nofast	 Lists only the name of folders, with no additional information.  This is faster because the folders need not be read.

       -help	 Prints a list of the valid options to this command.

       -list
       -nolist	 Lists the contents of the folder-stack.  No +folder argument is allowed with this option.

       -pack
       -nopack	 Re-numbers messages in the folders.  Messages are re-numbered sequentially, and any gaps  in  the  numbering  are  removed.   The
		 default operation is -nopack, which does not change the numbering in the folder.

       -pop	 Discards  the	top of the folder-stack, after setting the current folder to that value.  No +folder argument is allowed with this
		 option.  This corresponds to the operation in the C-shell; see The -push and -pop options are mutually exclusive: the last occur-
		 rence of either one overrides any previous occurrence of the other.

       -push	 Pushes  the  current  folder  onto  the  folder-stack, and makes the +folder argument into the current folder.  If +folder is not
		 given, the current folder and the top of the folder-stack are exchanged.  This corresponds to the operation in the  C-shell;  see
		 The  -push switch and the -pop switch are mutually exclusive: the last occurrence of either one overrides any previous occurrence
		 of the other.

       -recurse
       -norecurse
		 Lists folders recursively.  Information on each folder is displayed, followed by information on any  sub-folders  which  it  con-
		 tains.

       -total
       -nototal  Displays  only the total number of messages and folders in your Mail directory.  This option does not print any information about
		 individual folders.  It can be suppressed using the -nototal option.

       The defaults for are:

	      +folder defaults to all
	      msg defaults to none
	      -nofast
	      -noheader
	      -nototal
	      -nopack
	      -norecurse

Restrictions
       MH does not allow you to have more than 100 folders at any level in your Mail directory.

Profile Components
       Path:		 To determine your MH directory
       Folder-Protect:	 To set protections when creating a new folder
       Folder-Stack:	 To determine the folder stack
       lsproc:		 Program to list the contents of a folder

Files
       The user profile.

See Also
       csh(1), folder(1mh), refile(1mh), mhpath(1mh)

																      folders(1mh)
All times are GMT -4. The time now is 05:41 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy