|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
I would like to compare 2 directory structions & get a list of the files that are different from eachother.
For ex. if /dir1/sub/file.php is different from /dir2/sub/file.php, I want this command to output "sub/file.php" . Then I will run a script to get the actual differences in the files that are outputted. What is the quickest way to do this? I tried looping through the files in one structure and comparing them with the same files in the other structure. But I'm stuck because I can't figure out how to get the filename out of a full path. Basically, how can I get "file.php" from the string "/dir1/sub/file.php" ? |
|
#2
|
||||
|
||||
|
You could do something like this:
ls -1 /path/to/dir1 | sort > /path/to/dirlist1.txt ls -1 /path/to/dir2 | sort > /path/to/dirlist2.txt diff /path/to/dirlist1.txt /path/to/dirlist2.txt | less
__________________
Up the Irons What Would Jimi Do? Smash amps. Burn guitar. Take the groupies home. "Death Before Dishonour, my Friends!!" - Bruce D ickinson, Iron Maiden Aug 20, 2005 @ OzzFest Down with Sharon Osbourne Puzzle of the Month solved by Keath and KevinADC, superior perl programmers of the month Looking for a perl job with kick-*** programmers in a well-known NASDAQ listed tech company with branches in the US and Europe? We're hiring. PM me for details. Requirements |
|
#3
|
|||
|
|||
|
it is not very clear what you want, what Scorpions4ever said it's to compare just the filenames, not content..
you need for content? and can those sub/ have other sub-directories? |
![]() |
| Viewing: Dev Shed Forums > Operating Systems > UNIX Help > Comparing directory structures |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|