Author Topic: (SOLVED) mv command with -i option not working properly?  (Read 414 times)

Offline lfever

  • Full Member
  • ***
  • Posts: 87
  • Windows are Fragile!
(SOLVED) mv command with -i option not working properly?
« on: July 11, 2012, 05:23:23 PM »
In using the mv command with the option -i to rename a file (mv -i fileold filenew) the -i should cause me to be prompted before overwriting files. This is not happening, the file is renamed without any prompt. Probably something simple that I am overlooking but it has given me a headache trying to figure out what the problem is  :'( Can anyone tell me what I may be doing wrong?

Thanks
lfever
« Last Edit: July 11, 2012, 08:33:28 PM by lfever »
PCLinuxOS is the best!!!  KDE & LXDE user :)

Registered Linux User #445923

Offline djohnston

  • PCLinuxOS Tester
  • Hero Member
  • *******
  • Posts: 6227
  • I don't do Windows
Re: mv command with -i option not working properly?
« Reply #1 on: July 11, 2012, 06:36:36 PM »
Your syntax is correct.

Code: [Select]
darrel@AMD64:  57 items 792Kb -> mv -i file1 file2
mv: overwrite `file2'?

Can you show an example of it not working?

Bare metal                           VBox
AMD Athlon 7750 Dual-Core    Single core
4GiB RAM                              1GiB RAM
nVidia GeForce FX 5200          64MB video
LXDE 32bit                            KDE 64bit

Registered Linux User #416378

Offline lfever

  • Full Member
  • ***
  • Posts: 87
  • Windows are Fragile!
Re: mv command with -i option not working properly?
« Reply #2 on: July 11, 2012, 07:14:50 PM »
Quote
Can you show an example of it not working?

Code: [Select]
[msswanson@linuxlover ~]$ mv -i file_rename file_rename_old
[msswanson@linuxlover ~]$

The file is renamed with no prompting!
I tried this on another distro and am getting the same results.  ???

Now I really have a headache!  :(
PCLinuxOS is the best!!!  KDE & LXDE user :)

Registered Linux User #445923

Online Old-Polack

  • Administrator
  • Super Villain
  • *****
  • Posts: 11597
  • ----IOFLU----
Re: mv command with -i option not working properly?
« Reply #3 on: July 11, 2012, 07:22:48 PM »
Quote
Can you show an example of it not working?

Code: [Select]
[msswanson@linuxlover ~]$ mv -i file_rename file_rename_old
[msswanson@linuxlover ~]$

The file is renamed with no prompting!
I tried this on another distro and am getting the same results.  ???

Now I really have a headache!  :(


From man mv;

-i, --interactive
              prompt before overwrite


If there is nothing being overwritten, there will be no prompt.
Old-Polack

Of what use be there for joy, if not for the sharing thereof?



Lest we forget...

Offline lfever

  • Full Member
  • ***
  • Posts: 87
  • Windows are Fragile!
Re: mv command with -i option not working properly?
« Reply #4 on: July 11, 2012, 07:39:52 PM »
Quote
From man mv;

-i, --interactive
              prompt before overwrite

If there is nothing being overwritten, there will be no prompt.

Isn't the file name being rewritten?
PCLinuxOS is the best!!!  KDE & LXDE user :)

Registered Linux User #445923

Offline gseaman

  • PCLinuxOS Tester
  • Hero Member
  • *******
  • Posts: 3801
Re: mv command with -i option not working properly?
« Reply #5 on: July 11, 2012, 08:09:23 PM »
I learned something new. This is how it works on my machine.
Quote
[galen@localhost ~]$ echo "dummy" > dummy.txt
[galen@localhost ~]$ mv -i dummy.txt dummy.txt.save
No prompt.
Quote
[galen@localhost ~]$ echo "dummy-new" > dummy.txt
[galen@localhost ~]$ mv -i dummy.txt dummy.txt.save
mv: overwrite `dummy.txt.save'? y
[galen@localhost ~]$
If dummy.txt.save doesn't exist, there is no prompt. The second time, it already exists, so there is a prompt.

I hope this is helpful.

Galen

Offline lfever

  • Full Member
  • ***
  • Posts: 87
  • Windows are Fragile!
Re: mv command with -i option not working properly?
« Reply #6 on: July 11, 2012, 08:26:38 PM »
Quote
If dummy.txt.save doesn't exist, there is no prompt. The second time, it already exists, so there is a prompt.

I hope this is helpful.

Galen

Thanks Galen,
Getting the same results here. So the prompt will only show when renaming a file to an already existing file so as not to inadvertently overwrite the file unless your sure you want to do so or at least warn you.  :)
PCLinuxOS is the best!!!  KDE & LXDE user :)

Registered Linux User #445923