The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
shell script to search content of file with timestamps in the directory psychobeauty Shell Programming and Scripting 10 04-21-2008 05:37 AM
finding difference between 2 directory recursively yayati Shell Programming and Scripting 2 04-09-2008 10:37 AM
content need changes- many files swchee Shell Programming and Scripting 3 10-05-2006 12:29 PM
Can't view directory content - SUNOS nhatch UNIX for Advanced & Expert Users 2 06-27-2006 03:23 AM
Use of unzip with content files > 2Gb tcarlson Filesystems, Disks and Memory 2 09-17-2003 04:33 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 02-08-2007
singhald007 singhald007 is offline
Registered User
  
 

Join Date: Feb 2007
Posts: 2
I want to record the difference in the content of files in different directory

Hi All

I am very new to the Unix shell scripting ,, could you pleae help me to generate the output file having the filename and path which files having the difference in the contents in the two directory. all files in both directory have the same name and format.

input directory /edc/input1/ it also can have sub directory
/edc/input2/ it also can have sub directory
output file diffout having path and name fo file.

please let me know if this requremnt are not clear
please provide me some sample script.

thanks

Singh
  #2 (permalink)  
Old 02-08-2007
hegemaro hegemaro is offline
Registered User
  
 

Join Date: Feb 2006
Location: Schenectady, NY
Posts: 134
If I understand correctly, try this

cd /edc/input1 ; find . -type f | sort > /tmp/input1.lst
cd /edc/input2 ; find . -type f | sort > /tmp/input2.lst
diff /tmp/input1.lst /tmp/input2.lst


From the output, lines that begin with a less-than sign '<' exist only in /edc/input1 and those beginning with a greater-than sign '>' exist only in /etc/input2. To see which files exist in BOTH directories, use the join(1) command

join /tmp/input1.lst /tmp/input2.lst
  #3 (permalink)  
Old 02-13-2007
singhald007 singhald007 is offline
Registered User
  
 

Join Date: Feb 2007
Posts: 2
I want to record the difference in the content of files in different directorys

Hi hegemaro

diff /tmp/input1.lst /tmp/input2.lst

is not giving any output. beacuse it is having the same file name in both of the list. i want to print the filename along wiht the path, which having diffrent contents, could u please giv me any idea how can we do this ..

Singhal
  #4 (permalink)  
Old 02-13-2007
anbu23 anbu23 is offline Forum Advisor  
Registered User
  
 

Join Date: Mar 2006
Location: Bangalore,India
Posts: 1,398
Code:
ls /dir1 | while read x
do
str=$(diff /dir1/$x /dir2/$x )
[[ -n "$str" ]] && echo $x
done
Sponsored Links
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 07:51 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language translation by Google.
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0