0

Hi
i need to have a update for a file that updates only the last modified content from another file....

say for example....if file A is having content like
.
.
.
hatxxxx
catxxxx
ratxxxx
and file B(the file to be updated is having content as
hatxxxx
catxxxx
then file B has to be updated/appended with the last modified content(i.e rat in this case) so as to look like
hatxxxx
catxxxx
ratxxxx
plz help someone with a script.

3
Contributors
2
Replies
3
Views
9 Years
Discussion Span
Last Post by radoulov
0

Hey there

You can use patch to do that, with diff:

diff fileb filea >DIFF
patch -p0 -i DIFF fileb

You can also do it this way - less hassle and less confusing sometimes:

cat filea fileb|sort -u

There are probably more and better ways to do it depending on exactly what you want (for instance the cat piped to sort will rearrange your data using the default alphabetical sort)

Hope that helps :)

, Mike

0
printf "%s\n" "$(tail -1 fileA)">>fileB

Or perhaps I misread the question :)

Otherwise:

printf "%s\n" "$(grep -vf fileB fileA)">>fileB
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.