cp - no to all option? | Unix Linux Forums | UNIX for Dummies Questions & Answers

  Go Back    


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

cp - no to all option?

UNIX for Dummies Questions & Answers


Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 08-18-2006
td_kuoj3 td_kuoj3 is offline
Registered User
 
Join Date: Aug 2006
Last Activity: 18 August 2006, 3:57 PM EDT
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
cp - no to all option?

Hi,

Is there a no to all option when copying a bunch of files? instead of pressing enter endlessly.

Thanks
Sponsored Links
    #2  
Old 08-18-2006
RTM's Avatar
RTM RTM is offline Forum Advisor  
Registered User
 
Join Date: Apr 2002
Last Activity: 3 April 2014, 2:50 PM EDT
Location: On my motorcycle
Posts: 3,092
Thanks: 1
Thanked 30 Times in 9 Posts
What OS and version are you using? What is the exact command?

On Solaris, if I run the following it does not cause me to hit return for each file.

$ cp ./dirone/*.* ./dirtwo/

If I then change it to interactive mode, I have to hit y and return for each file I want to overwrite

$ cp -i ./dirone/*.* ./dirtwo/

There are no options which would cause me to have to hit return for each file unless you mean you are doing each file individually (which means you should use a wildcard character such as * to give yourself less 'returns').

Last edited by RTM; 08-18-2006 at 02:34 PM..
Sponsored Links
    #3  
Old 08-18-2006
tmarikle tmarikle is offline Forum Advisor  
Registered User
 
Join Date: Jan 2005
Last Activity: 27 September 2011, 12:36 PM EDT
Posts: 683
Thanks: 0
Thanked 4 Times in 4 Posts
Probably the OP has an alias set up for him like alias cp='cp -i'
    #4  
Old 08-18-2006
vgersh99's Avatar
vgersh99 vgersh99 is offline Forum Advisor  
Forum Advisor
 
Join Date: Feb 2005
Last Activity: 26 July 2014, 5:29 AM EDT
Location: Foxborough, MA
Posts: 7,644
Thanks: 150
Thanked 577 Times in 542 Posts
... or he/she/it [the OP that is] has permission issues on the 'destination' file/directory.
Sponsored Links
    #5  
Old 08-18-2006
td_kuoj3 td_kuoj3 is offline
Registered User
 
Join Date: Aug 2006
Last Activity: 18 August 2006, 3:57 PM EDT
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
OS: AIX 5.3

Let me restate my problem again.

i want to copy dirone to dirtwo, they're similiar, but there are some extra files in dirone that dirtwo doesn't have, going through them one by one takes way too long. So I use the following command to copy one directory to the second.

cp -R -h -i /dirone/* /dirtwo

I wanted -i in there because I do NOT want to overwrite, the directory is huge and i had to sit here pressing enter for 1.5 hours.

Now my question is, is there an option that is "no to all"?

Thanks, any help is much appreciated.
Sponsored Links
    #6  
Old 08-18-2006
tansha tansha is offline
Registered User
 
Join Date: May 2006
Last Activity: 13 February 2009, 1:52 PM EST
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts
Hi ,

I would instead use a simple script like the one below to achieve same.

Hope this helps.




#! /bin/ksh

export SRC_DIR=/YOUR/SOURCE/DIRECTORY
export TGT_DIR=/YOUR/TARGET/DIRECTORY

for i in `ls $SRC_DIR`
do
echo $i

if [ -f $TGT_DIR/$i ]
then
echo " File exists - will not overwrite it !!!"
else
echo " File $i is not present on target directory - copying same"
cp $SRC_DIR/$i $TGT_DIR/$i
fi
done
Sponsored Links
    #7  
Old 08-18-2006
Glenn Arndt's Avatar
Glenn Arndt Glenn Arndt is offline Forum Advisor  
Anomalous Lurker
 
Join Date: Feb 2006
Last Activity: 2 February 2012, 9:30 AM EST
Location: Indianapolis, IN
Posts: 255
Thanks: 0
Thanked 2 Times in 2 Posts
Use my favorite command of all time: yes


Code:
yes n | cp -R -h -i /dirone/* /dirtwo

Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
recently introduced to the newer option for find...does an older option exist? mr_manny Shell Programming and Scripting 2 07-20-2010 12:56 PM
BRU -T option mojoman UNIX for Dummies Questions & Answers 1 01-12-2010 03:24 PM
Can there be a better option? shahdharmit Shell Programming and Scripting 2 12-18-2009 01:44 AM
bad option(s) with awk rajeshorpu Shell Programming and Scripting 6 11-08-2009 08:19 AM
option followed by : taking next option if argument missing with getopts gurukottur Shell Programming and Scripting 2 03-17-2008 12:46 PM



All times are GMT -4. The time now is 07:09 AM.