SUSE / openSUSEThis Forum is for the discussion of Suse Linux.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Distribution: Red Hat Enterprise Linux, Debian & Ubuntu
Posts: 92
Rep:
SOLVED: 'cp -rv .*' recurses into the parent directory??? [In bash, not in zsh]
Hey all,
I'm testing out SuSE Pro 9.1 , and noticed some very odd behavior with 'cp'.
If I try to copy dotfiles, 'cp' recurses into '..' , which seems completely wrong. I can't replicate it on other Unixes (Trying on Solaris 8 with GNU ls, Redhat 9, etc).
Anyone else see this? I'm not quite sure how I can copy multiple dotfiles with this bug.
Here's an example:
linux:/tmp # cp -rv /etc/skel/.* /tmp/
##### First, it does the correct thing, and copies the dotfiles:
`/etc/skel/./Documents/.directory' -> `/tmp/./Documents/.directory'
`/etc/skel/./.exrc' -> `/tmp/./.exrc'
##### But then it starts to go into /etc/skel/../ , which it shouldn't do.
`/etc/skel/../X11/fs/config' -> `/tmp/X11/fs/config'
`/etc/skel/../X11/twm/system.twmrc' -> `/tmp/X11/twm/system.twmrc'
`/etc/skel/../X11/xdm/Xresources' -> `/tmp/X11/xdm/Xresources'
`/etc/skel/../X11/xdm/README.security' -> `/tmp/X11/xdm/README.security'
`/etc/skel/../X11/xdm/Xaccess' -> `/tmp/X11/xdm/Xaccess'
##### Needless to say, my drive fills up within a matter of minutes.
This is with the folllowing version of cp:
linux:/tmp # cp --version
cp (coreutils) 5.2.1
Thanks all,
-= Stefan
Last edited by stefanlasiewski; 07-25-2005 at 06:43 PM.
Well, unfortunately .* includes .. which means it will and should recurse into the parent directory. The "." and ".." are actually just like any named directory. That is why we should always take care in doing anything like chmod -R .* or rm -rf .* or anything else of that nature because the system is going to do exactly what you asked it to do, for better or worse.
Distribution: Red Hat Enterprise Linux, Debian & Ubuntu
Posts: 92
Original Poster
Rep:
I'll have to disagree with you there. This only seems to be a problem on SuSe, or with a newer version of cp. There needs to be some way of copying multiple dotfiles, and you when creating a new user there needs to be a way to populate the home directory with the appropriate dotfiles.
Here's the behavior on Solaris 8, with the default cp
Glad you figured it out, I was just about to say that I see that behavior on all my systems, but I'm a bash user and am quite used to that at this point.
Distribution: Red Hat Enterprise Linux, Debian & Ubuntu
Posts: 92
Original Poster
Rep:
Now I remember a time in 1997 when I ran 'rm -r ~/.*' and it erased a huge chunk of my system. GNU utils weren't very common, and Solaris cp didn't have a '--verbose' option-- the rm job just took a long time. I always thought that was a nasty bug in 'cp', but
now I'm more clear on what happened way back then...
I think it's time to revise my habits with using '.*'.
Dang...
Last edited by stefanlasiewski; 02-02-2005 at 05:45 PM.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.