Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

cp command

Status
Not open for further replies.

snowsmart

IS-IT--Management
May 24, 2005
37
CA
I want to copy files from A dir to B Dir, but I only need copy the ones that does not exist in the B dir.

Please help

thanks




 
Assuming you dont have 100s of files to move, this will do the trick:

Code:
cd /location/A
for foo in `ls`
do
  if [ ! -e /location/B/$foo ]
  then
    cp /location/A/$foo /location/B/
  fi
done
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top