LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-03-2013, 05:10 PM   #16
KRowe
LQ Newbie
 
Registered: Jun 2007
Posts: 2

Rep: Reputation: 0

I am a fan of this thread and like keeping it around. I'd like to improve this answer by noting that if the cp fails or test2 already contains files which are not wanted the previous solutions still wont' work. My solution:

Code:
rm -rf test2/* && cp -rf test1/* test2/ && rm -rf test1
 
Old 04-04-2013, 05:24 AM   #17
Pansmanse
LQ Newbie
 
Registered: Sep 2011
Posts: 4

Rep: Reputation: Disabled
This is very like my solution of 09-29-11 (allowing for the error of backslashes).
Perhaps should beware of Snooly's response at that time.
 
Old 04-04-2013, 01:15 PM   #18
SharpyWarpy
Member
 
Registered: Feb 2003
Location: Florida
Distribution: Fedora 18
Posts: 862

Rep: Reputation: 90
Quote:
Originally Posted by Pansmanse View Post
This is very like my solution of 09-29-11 (allowing for the error of backslashes).
Perhaps should beware of Snooly's response at that time.
Would you be so kind as to provide a link to that thread? It would save the rest of us a lot of time and trouble. Thanks.
 
Old 04-04-2013, 03:07 PM   #19
Pansmanse
LQ Newbie
 
Registered: Sep 2011
Posts: 4

Rep: Reputation: Disabled
See entries 9-13 on this thread.

Quote:
Originally Posted by snooly View Post
If you have slashes instead of backslashes, that makes a big difference. You should still be careful though. If you make a mistake and call the script with the wrong arguments, you might delete something you didn't mean to.

Imagine what will happen if the result of calling your script is the following command. Just imagine it, don't try it!!

# rm -r / # don't run this command!

That could possibly happen if your script has some slight problems or if you aren't very careful with how you call it.
 
  


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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
rename all files in a directory merlin23 Linux - Newbie 4 03-24-2005 12:02 PM
bash wont overwrite variables xushi Programming 4 03-02-2005 05:50 PM
will yum add kernel version or overwrite existing? Kropotkin Fedora 3 11-20-2004 06:10 AM
rename all files in my directory BabaKali Linux - Newbie 2 11-10-2004 05:27 PM
overwrite directory copy medamnit Linux - Newbie 1 05-26-2002 01:09 PM


All times are GMT -5. The time now is 01:36 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