LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (http://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Help - What happens when you give the following commands if the file named done alrea (http://www.linuxquestions.org/questions/linux-newbie-8/help-what-happens-when-you-give-the-following-commands-if-the-file-named-done-alrea-824994/)

zigtozag 08-08-2010 07:20 PM

Help - What happens when you give the following commands if the file named done alrea
 
What happens when you give the following commands if the file named done already exists in linux

zigtozag 08-08-2010 07:24 PM

What happens when you give the following commands if the file named done already exists?
o $ cp to_do done
o $ mv to_do don

Tinkster 08-08-2010 07:26 PM

Hi, welcome to LQ!

Those two commands (executed in a temporary directory, with a copy of a file) are
perfectly harmless. I recommend you TRY them - and then report your findings
back; both here and to your teacher, maybe?



Cheers,
Tink

zigtozag 08-08-2010 07:36 PM

I would if I had Linux, I do not have it just trying to learn about it

Tinkster 08-08-2010 07:39 PM

In that case ... download and install Cygwin; behaves like the real thing
in most aspects, works a treat under windwoes.


Cheers,
Tink

GrapefruiTgirl 08-08-2010 07:40 PM

A great idea for learning about Linux, would be to download & burn a LiveCD that you can boot and play with and learn with; you would not even need to install it if you don't want to - just boot it up and use it, and when you're done, you can shut down, remove the CD, and your computer is exactly as it was before you used the CD.

Nice LiveCD distros for beginners to Linux are Ubuntu and Mint, just as 2 examples.

Best of success!

zigtozag 08-08-2010 07:50 PM

I tried using the Fedora and Red Hat CD - I messed up and installed it and wiped out everything off my computer and I am afraid to use it again

Why is it so hard just to answer a question on this site, I was reading other post and it is truly unreal with some of the responses I am reading

Tinkster 08-08-2010 07:54 PM

Quote:

Why is it so hard just to answer a question on this site, I was reading other post and it is truly unreal with some of the responses I am reading
Because your question, viewed in isolation, smacks of homework. And answering
this is against our expressed rules.



Cheers,
Tink

Shadow_7 08-08-2010 08:12 PM

Plus you could have answered your own question. If you have a computer (how'd you get here if you don't?). And have a blank optical media or thumb drive. And probably in less time that it took to post the question.

But to answer your question, IT DEPENDS.

There are flags to NOT overwrite existing files. Whether or not they are enabled via an alias on your system DEPENDS. If that's a test question, then your teacher is an idiot. As BOTH answers are, from a certain POV, correct. Or it's an easy A as you can do no wrong.

In the meantime go out into the wilderness and learn.

http://distrowatch.com/

zigtozag 08-08-2010 08:32 PM

I thank you guys for being so nice about it, as I have just found out I have triple negative cancer, and I am just trying to get a little help, I really did not feel up to spending much time on this project, as I have to start my first chemo in the morning, so I guess right now I am feeling like an idiot and dont really care.

zigtozag 08-25-2010 06:33 AM

I am still battling the cancer, and taking the chemo makes you sick.. all prayers are welcome.

dv502 10-07-2010 05:47 PM

Quote:

Originally Posted by zigtozag (Post 4060193)
What happens when you give the following commands if the file named done already exists?
o $ cp to_do done
o $ mv to_do don

If the two commands are not setup with aliases, the file(s) would be overwritten. I assumed you meant to spell done instead of don.

Some distros will have commands setup with an aliases to warn you that it will overwrite or delete files before doing so. And some distros will not. In the bash shell the alias would look like this.

alias cp='cp -i'
alias mv='cp -i'

The -i is interactive mode, which means it will ask permission before doing the action.

If you don't want to be asked and still prevent overwriting add
the -n, --no-clobber option. Do not overwrite an existing file.

Tip

Have you ever hosed important files by using > when you meant to use >>

Add set -o noclobber to your /etc/bashrc or your hidden .bashrc in your home directory.

To disable noclobber so you can overwrite or append data to the file, use set +o noclobber

Hope this short tutorial helps.

Hope you get better too.


All times are GMT -5. The time now is 06:16 AM.