Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8520349
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T06:30:39+00:00 2026-06-11T06:30:39+00:00

First, I tried asking the same on askubuntu and I’m not getting far there…

  • 0

First, I tried asking the same on askubuntu and I’m not getting far there…
https://askubuntu.com/questions/186114/how-to-diff-two-folders-to-multiple-patch-files/186121#comment231985_186121

So, i’ll copy/paste here in hopes SO gives me a working solution…

I’m not much of a unix guy so I’ll just go ahead and ask:

I have a following problem – two folders with plenty of subfolders. I need to diff them.

I tried this:

diff -drupN vanila_kernel_3.0.8 my_kernel_3.0.8 > kernel.patch

and that results in a 185mb file… and not really what I want.

I want the result of the diff to be many smaller patches, ideally one for every changed file with the contents of the change. That means I have t ochange the way I use diff, and I need to put it in some sort of a loop… So i tried running this little script

for file in original_308/*.*; do
    diff -dupN "$file" "my_308/${file##*/}" > "$file".patch
done

But it doesn’t work :/

Ideally, I want to have a .patch file for every change, but having patches for files that changed in original would do just fine (as I could filter the newly added files and just copy them over)

Can someone provide me with a decent way to do this please?

UPDATE:
I know there are 231 altered files between these folders and 4546 newly added files… I’m just interested in generating those 231 patches. I even have a file containing those 231 filenames so that can be used in a script as well.

I used this to generate the changelog

diff -qdr -x *.o -x *.cmd -x *.d original_308 my_308 | sed "s/^.* and \(.*\) differ/\1/" | sort > changes.txt

and that just prints the filenames that changed, trailed by “only in my_308” files… the 231 files are on the top of that file (the first 231 lines)

So let’s make it clear – I want .patch files for source files. If the patches can end up in patches//file_name.c.patch that would be really great…

If you give me PERL scripts please tell me how to best use them since I do not understand that garbage. Please don’t fail me SO. I need to get this thing ported, tested and running and I’m wasting time on unix commands and untangible scripts ffs.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T06:30:41+00:00Added an answer on June 11, 2026 at 6:30 am

    Thanks to everyone for their contributions… Here’s the end result

    #!/bin/bash                               
    FOLDER_OLD="original"
    FOLDER_NEW="changed"
    FOLDER_PATCHES="./fresh_patches"
    
    echo "Generating changelog for $FOLDER_OLD --> $FOLDER_NEW"
    diff -qdr ${FOLDER_OLD} ${FOLDER_NEW} | sed "s/^.* and \(.*\) differ/\1/" | sort > newchanges.txt
    
    mkdir -p ${FOLDER_PATCHES}                                                                                                           
    for newfile in `find $FOLDER_NEW -type f`
    do
    sufix=${newfile#${FOLDER_NEW}/}
    oldfile="${FOLDER_OLD}/${sufix}"
    
    if [ -f $oldfile ]; then
        patchfile="${FOLDER_PATCHES}/`echo $sufix |sed 's/\//_/g'`.patch"
        if [ "`diff $oldfile $newfile`" != "" ]; then
            echo "Make patch ${patchfile}"
            diff -dupN "$oldfile" "$newfile" > "$patchfile"
        fi
    else
    patchfile="${FOLDER_PATCHES}/ADDONS/${newfile#$FOLDER_NEW}"
        echo "Copy $newfile --> $patchfile"
        mkdir -p "`dirname ${patchfile}`"
        cp $newfile $patchfile
    fi
    done
    

    The script first generates a list of changed files and files unique only to the new project/folder; then it generates a patch file for every file and copies the newly added files to the ADDONS folder (unique to the new project)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

this is my first time asking a question here. I tried to be well
I am having trouble getting minizip to work on android. I first tried to
I tried asking this the other day, and admittedly did not phrase the question
I am trying to communicate between an applet and a servlet. I first tried
At first,I tried to use ppm and cpanm to install Tk module.But failed to
I first time tried to subClassed an NSDate to give it 2 methods that
Controller First I tried this: [HttpPost] public ActionResult Edit(JournalEntry journalentry) { if (ModelState.IsValid) {
So I am trying to update NodeJS and running into issues. First I tried
I am trying to parse the resultlist of http://mobile.de . First I tried it
I just tried my first steps with grid . I would like to set

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.