LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 01-30-2003, 07:20 AM   #1
trubi
LQ Newbie
 
Registered: Jan 2003
Distribution: RedHat 7.3 (Valhalla)
Posts: 25

Rep: Reputation: 15
A simple newbie question !


I'm trying to write a script and i need to use the copy (cp) to move some directories and I want this to be done without promting to override
I want to override the same names (files and dirs) with the new ones (updated)

But I didn't get it from the help

Can you tell me Please How to use cp with always saying "Y"

Maybe the question would seem stupid but ....I am
 
Old 01-30-2003, 07:23 AM   #2
trickykid
LQ Guru
 
Registered: Jan 2001
Posts: 24,149

Rep: Reputation: 256Reputation: 256Reputation: 256
Have you checked the man pages ? I believe there is a force flag you can use which should copy without prompting.

cp -f [/source] [/destination]
 
Old 01-30-2003, 07:29 AM   #3
trubi
LQ Newbie
 
Registered: Jan 2003
Distribution: RedHat 7.3 (Valhalla)
Posts: 25

Original Poster
Rep: Reputation: 15
Ok I tried it
but dosn't work as I wish, it asks again for "y" ...

sample: # cp -fv -R /home/mike/test/* /home/mike/rute/

That is what I want to do
Where is my mistake ?

I rute I already have the test and its subfolders
 
Old 01-30-2003, 07:32 AM   #4
MasterC
LQ Guru
 
Registered: Mar 2002
Location: Salt Lake City, UT - USA
Distribution: Gentoo ; LFS ; Kubuntu
Posts: 12,612

Rep: Reputation: 68
What about "yes".

Also, maybe there is a "quiet" option? Check the man page for flags on such options. I'm leaning towards removing the -v option though, as this will act a bit against you.

Cool
 
Old 01-30-2003, 07:37 AM   #5
MasterC
LQ Guru
 
Registered: Mar 2002
Location: Salt Lake City, UT - USA
Distribution: Gentoo ; LFS ; Kubuntu
Posts: 12,612

Rep: Reputation: 68
Ya know what, post up your .bashrc file. I am wondering if your distro "automatically" creates aliases for cp to force an interactive option.

The -f should have worked.
 
Old 01-30-2003, 07:39 AM   #6
trubi
LQ Newbie
 
Registered: Jan 2003
Distribution: RedHat 7.3 (Valhalla)
Posts: 25

Original Poster
Rep: Reputation: 15
I didn't find any "quiet" option so that's whay I'm asking here
or maybe I don't understand exactly the man ...

The -v is not the problem
 
Old 01-30-2003, 07:41 AM   #7
MasterC
LQ Guru
 
Registered: Mar 2002
Location: Salt Lake City, UT - USA
Distribution: Gentoo ; LFS ; Kubuntu
Posts: 12,612

Rep: Reputation: 68
Yeah, I don't see it either. I'm reading over some man pages, only mv seems to talk about supressing prompting.

Does, "yes" not do the job good enough either?

Cool
 
Old 01-30-2003, 07:44 AM   #8
trubi
LQ Newbie
 
Registered: Jan 2003
Distribution: RedHat 7.3 (Valhalla)
Posts: 25

Original Poster
Rep: Reputation: 15
Here is the bashrc - root

# /etc/bashrc

# System wide functions and aliases
# Environment stuff goes in /etc/profile

# by default, we want this to get set.
# Even for non-interactive, non-login shells.
if [ "`id -gn`" = "`id -un`" -a `id -u` -gt 99 ]; then
umask 002
else
umask 022
fi

# are we an interactive shell?
if [ "$PS1" ]; then
if [ -x /usr/bin/tput ]; then
if [ "x`tput kbs`" != "x" ]; then # We can't do this with "dumb" terminal
stty erase `tput kbs`
elif [ -x /usr/bin/wc ]; then
if [ "`tput kbs|wc -c `" -gt 0 ]; then # We can't do this with "dumb" terminal
stty erase `tput kbs`
fi
fi
fi
case $TERM in
xterm*)
if [ -e /etc/sysconfig/bash-prompt-xterm ]; then
PROMPT_COMMAND=/etc/sysconfig/bash-prompt-xterm
else
PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME%%.*}:${PWD/$HOME/~}\007"'
fi
;;
screen)
PROMPT_COMMAND='echo -ne "\033_${USER}@${HOSTNAME%%.*}:${PWD/$HOME/~}\033\\"'
;;
*)
[ -e /etc/sysconfig/bash-prompt-default ] && PROMPT_COMMAND=/etc/sysconfig/bash-prompt-default
;;
esac
[ "$PS1" = "\\s-\\v\\\$ " ] && PS1="[\u@\h \W]\\$ "

if [ "x$SHLVL" != "x1" ]; then # We're not a login shell
for i in /etc/profile.d/*.sh; do
if [ -r "$i" ]; then
. $i
fi
done
fi
fi
# vim:ts=4:sw=4
 
Old 01-30-2003, 07:48 AM   #9
MasterC
LQ Guru
 
Registered: Mar 2002
Location: Salt Lake City, UT - USA
Distribution: Gentoo ; LFS ; Kubuntu
Posts: 12,612

Rep: Reputation: 68
What does:
/etc/sysconfig/bash-prompt-default
look like then?

Also, have you given "yes" a try yet? yes prints a 'y' basically accepting everything for you. Sounds like it might be what you want...

Cool
 
Old 01-30-2003, 07:52 AM   #10
trubi
LQ Newbie
 
Registered: Jan 2003
Distribution: RedHat 7.3 (Valhalla)
Posts: 25

Original Poster
Rep: Reputation: 15
Where exactly shall I put this "yes" ?
 
Old 01-30-2003, 07:53 AM   #11
MasterC
LQ Guru
 
Registered: Mar 2002
Location: Salt Lake City, UT - USA
Distribution: Gentoo ; LFS ; Kubuntu
Posts: 12,612

Rep: Reputation: 68
Where are you typing the command? (not at home, and not on linux... these are just educated guesses):

If it's just a one time thing:
cp -a /path/to/files /path/to/new/files &&
yes

I would think would work just fine? Maybe a pipe is necessary:
cp -a /path/to/files /path/to/new/files | yes

Cool
 
Old 01-30-2003, 07:58 AM   #12
trubi
LQ Newbie
 
Registered: Jan 2003
Distribution: RedHat 7.3 (Valhalla)
Posts: 25

Original Poster
Rep: Reputation: 15
Here is sn example :
cp -R -f /home/trifon/InterBase/* /home/trifon/rute/ && yes

and again it asks me for y or n
 
Old 01-30-2003, 08:00 AM   #13
MasterC
LQ Guru
 
Registered: Mar 2002
Location: Salt Lake City, UT - USA
Distribution: Gentoo ; LFS ; Kubuntu
Posts: 12,612

Rep: Reputation: 68
Try the pipe.

cp -aRf /home/trifon/InterBase /home/trifon/rute | yes

Cool
 
Old 01-30-2003, 08:11 AM   #14
trubi
LQ Newbie
 
Registered: Jan 2003
Distribution: RedHat 7.3 (Valhalla)
Posts: 25

Original Poster
Rep: Reputation: 15
again nothing :

y
y
y..................
 
Old 01-30-2003, 08:14 AM   #15
MasterC
LQ Guru
 
Registered: Mar 2002
Location: Salt Lake City, UT - USA
Distribution: Gentoo ; LFS ; Kubuntu
Posts: 12,612

Rep: Reputation: 68
Shootin in the dark now, how about:
yes | cp -aRf /bla /bla

A reverse pipe?

What's in:
/etc/sysconfig/bash-prompt-default
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Stupid Newbie with simple question... tufkid Linux - Newbie 11 12-25-2004 11:40 PM
Simple newbie question - how to... mazzo Linux - Wireless Networking 4 09-02-2004 04:34 PM
simple newbie question naijaguy Red Hat 1 08-11-2004 11:55 PM
Simple newbie question izrahi Linux - Newbie 1 08-11-2004 06:07 PM
Iptables newbie / simple question wr3ck3d Linux - Networking 2 03-06-2003 09:08 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 10:59 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration