Hi Experts,

I need to have a shell script to compare two directories and if new file is created in Dir1 it should be copied to Dir2.

can some one help me, i am not aware of scripting

Thanks & Regards
Suresh

Recommended Answers

All 3 Replies

In the purple band at the top of the page is a search box. Type into that search box compare two directories and press the [search] button. This problem has already been answered more than a few times on DaniWeb

You need to set the dir path if the directories are in different location. This is a simple way of doing the copy work.

#!/bin/sh
diff d1 d2 | awk -F: '{print $2}'|while read a 
do
cp -r d1/$a d2
done

When the purple band at the top of the page in the search box. Type in this field of research to compare two directories and press. This problem has already been answered more than a couple of times DaniWeb.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.