[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]
Re: [OT] How to create a 'patch' with full files?
- From: "Chester R. Hosey" <Chester Hosey gianteagle com>
- To: wolf2k5 <wolf2k5 gmail com>, "Red Hat Enterprise Linux 4 (Nahant) Discussion List" <nahant-list redhat com>
- Cc:
- Subject: Re: [OT] How to create a 'patch' with full files?
- Date: Tue, 26 Jul 2005 10:24:09 -0400
On Mon, 2005-07-25 at 15:45 +0200, wolf2k5 wrote:
> Hi all,
>
> [snip]
>
> Is there any way to automate the last step of this process (figuring
> out the modified files and putting them in a directory)?
>
> That could be probably done with some piping between diff, awk and cp,
> but I don't have the necessary skills for that.
Try "cut" -- it's not quite awk, but works in a pinch and is a little
easier to learn.
> Is there any script already available?
There is now ;)
> Thanks in advance.
Nobody's touched this, so I'll give it a stab.
You basically have two tasks -- to get the list of files, and to do
something productive with it.
You can pull out the list of files using either of:
diff -qr rev0 rev1 | cut -f 4 -d ' ' #second field, space-delimited
diff -qr rev0 rev1 | awk '{print $4;}'
I'd do something like the following:
#!/bin/sh
# run from directory containing rev0 and rev1
DEST=/tmp/newtreeroot
mkdir $DEST
for FILE in `diff -qr rev0 rev1 | awk '{print $4;}'`
do
# Get the directory portion of the filename
DIR=`dirname $FILE`
# You could just _always_ run mkdir if you
# didn't know how to test for $DIR...
[ -d $DIR ] || mkdir -p $DIR
# Copy the file to the destination tree
cp $FILE $DEST/$DIR
done
#EOF
The most important constructs are the 'for' command and use of backtics
(they're in the ~ key -- just don't press shift) to insert command
output into the command line. You could extend it to take command-line
arguments, etc., but it's a quick solution. Let me know off-list if I
can help further.
Chet
[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]