You are not logged in.

#1 2008-04-27 00:31:36

snafle
Member
Registered: 2008-04-08
Posts: 41

File Deletion: or, Interesting CP behaviour

Movie file called jarhead.mkv, folder called "Movies". I run

sudo cp jarhead.mkv Movies

to get one into the other. In doing so, I "lose" the entire contents of the "Movies" folder. Should I have run

sudo cp jarhead.mkv Movies/

or something?

Last edited by snafle (2008-04-27 00:32:18)

Offline

#2 2008-04-27 00:37:48

snafle
Member
Registered: 2008-04-08
Posts: 41

Re: File Deletion: or, Interesting CP behaviour

Yes indeed I should. Lucky I still have the DVDs. Can anyone explain how a single / can make it possible to molest my files, and possibly give a tiny amount of sympathy?

Offline

#3 2008-04-27 01:14:48

tigrmesh
IRC Op
From: Florida, US
Registered: 2007-12-11
Posts: 794

Re: File Deletion: or, Interesting CP behaviour

That's terrible. 

I haven't made that mistake (yet).  But only because I always stuck the / at the end of the directory.  I didn't know what it did, but I thought it couldn't hurt to put it there...

You may get some consolation from this thread:  http://bbs.archlinux.org/viewtopic.php?id=11728.

Offline

#4 2008-04-27 08:21:18

.:B:.
Forum Fellow
Registered: 2006-11-26
Posts: 5,819
Website

Re: File Deletion: or, Interesting CP behaviour

Cp exhibits similar behaviour wink. Normally, if you use shell (bash) expansion, it will put a slash at the end automatically. Nevertheless, you cannot create a file and directory with the same name in the same folder (ie ~/Movies folder and  ~/Movies file), so it still looks a bit awkward. Did you set any aliases for mv?

Hmm...

Works fine right here:

[stijn@hermes ~]$ mkdir test
[stijn@hermes ~]$ mv 18\ Don\'t\ Ask\,\ Don\'t\ Tell.avi test
'18 Don\'t Ask, Don\'t Tell.avi' -> 'test/18 Don\'t Ask, Don\'t Tell.avi'

Got Leenucks? :: Arch: Power in simplicity :: Get Counted! Registered Linux User #392717 :: Blog thingy

Offline

#5 2008-04-27 09:19:27

shining
Pacman Developer
Registered: 2006-05-10
Posts: 2,043

Re: File Deletion: or, Interesting CP behaviour

snafle wrote:

Movie file called jarhead.mkv, folder called "Movies". I run

sudo cp jarhead.mkv Movies

to get one into the other. In doing so, I "lose" the entire contents of the "Movies" folder. Should I have run

sudo cp jarhead.mkv Movies/

or something?

uh?

> touch jarhead.mkv
> mkdir Movies
> cp jarhead.mkv Movies
> ls *
jarhead.mkv

Movies:
jarhead.mkv
>

pacman roulette : pacman -S $(pacman -Slq | LANG=C sort -R | head -n $((RANDOM % 10)))

Offline

#6 2008-04-27 09:45:17

Stefan Husmann
Member
From: Germany
Registered: 2007-08-07
Posts: 1,391

Re: File Deletion: or, Interesting CP behaviour

snafle, are you really sure the directory was already there when you copied the file?

and now, is Movies really a directory or is it a file?

Offline

#7 2008-04-27 09:57:05

snafle
Member
Registered: 2008-04-08
Posts: 41

Re: File Deletion: or, Interesting CP behaviour

It was a folder with about a hundred movies in it, now it's a folder with a movie called jarhead.mkv
I'm pretty certain this is just one of the "learning experiences" that'll teach me to understand the commands I use first.

Shining: Why use the "touch" comand there.

Offline

#8 2008-04-27 10:37:38

Lachkater
Member
From: Germany
Registered: 2008-02-04
Posts: 40

Re: File Deletion: or, Interesting CP behaviour

touch creates a new empty file. It was just for the example.
Besides that why do you use sudo?

Offline

#9 2008-04-27 10:57:51

Ramses de Norre
Member
From: Leuven - Belgium
Registered: 2007-03-27
Posts: 1,289

Re: File Deletion: or, Interesting CP behaviour

Strange:

$ touch test1
$ mkdir dir
$ touch dir/{test2,test3}
$ ls dir/
test2  test3
$ cp test1 dir
$ ls dir/
test1  test2  test3
$

I have no aliases for cp in my bashrc.

Offline

#10 2008-04-27 12:03:22

snafle
Member
Registered: 2008-04-08
Posts: 41

Re: File Deletion: or, Interesting CP behaviour

the files were in /mnt, not my home dir.

Offline

#11 2008-04-27 17:03:50

Sigi
Member
From: Thurgau, Switzerland
Registered: 2005-09-22
Posts: 1,131

Re: File Deletion: or, Interesting CP behaviour

That doesn't change anything...

edit: yay, 1000st post big_smile

Last edited by Sigi (2008-04-27 17:04:34)


Haven't been here in a while. Still rocking Arch. smile

Offline

#12 2008-04-27 17:13:21

bender02
Member
From: UK
Registered: 2007-02-04
Posts: 1,328

Re: File Deletion: or, Interesting CP behaviour

man cp wrote:

NAME
       cp - copy files and directories

SYNOPSIS
       cp [OPTION]... [-T] SOURCE DEST
       cp [OPTION]... SOURCE... DIRECTORY
       cp [OPTION]... -t DIRECTORY SOURCE...

DESCRIPTION
       Copy SOURCE to DEST, or multiple SOURCE(s) to DIRECTORY.

See the second possibility. When the last argument is really a directory, the file(s) is just copied in. Also, you say that now 'Movies' is a dir with jarhead.mkv in it - so cp did exactly what it should have done. The deletion of the other movies is in my opinion not in any way connected with cp. Also, the particular shell used (bash, ksh, tcsh,...) should have no effect on this.

Offline

#13 2008-04-27 18:06:27

rson451
Member
From: Annapolis, MD USA
Registered: 2007-04-15
Posts: 1,233
Website

Re: File Deletion: or, Interesting CP behaviour

are you sure that your media was mounted? that would make sense.  you were thinking there was a directory called movies, when really there was nothing. now your jarhead.mkv is named movies.  just my $.02.


archlinux - please read this and this — twice — then ask questions.
--
http://rsontech.net | http://github.com/rson

Offline

#14 2008-04-27 18:26:43

Stefan Husmann
Member
From: Germany
Registered: 2007-08-07
Posts: 1,391

Re: File Deletion: or, Interesting CP behaviour

Is is mounted now? If not maybe your data are not lost, but on an unmounted usbstick.

Offline

#15 2008-04-27 21:56:28

snafle
Member
Registered: 2008-04-08
Posts: 41

Re: File Deletion: or, Interesting CP behaviour

No, it's mounted. I know it is, because it's a 400 gigabyte disc mounted to a filesystem that resides on a 20 gigabyte partition. I couldn't fit the stuff on there if it wasn't there. And I know it is mounted, because I just ripped 70 gigs of movies onto it and queued up the conversions to x264.

@sigi: It should make a difference, since I don't have write permissions anywhere other than my home dir? At least I thought that's how it worked.

I ran this:

ls /mnt/video/movies

and it returned

jarhead.mkv

Offline

#16 2008-04-27 23:09:00

moljac024
Member
From: Serbia
Registered: 2008-01-29
Posts: 2,676

Re: File Deletion: or, Interesting CP behaviour

Have you modified your ~/.bashrc ? Please post it...


The day Microsoft makes a product that doesn't suck, is the day they make a vacuum cleaner.
--------------------------------------------------------------------------------------------------------------
But if they tell you that I've lost my mind, maybe it's not gone just a little hard to find...

Offline

#17 2008-04-28 00:08:24

bender02
Member
From: UK
Registered: 2007-02-04
Posts: 1,328

Re: File Deletion: or, Interesting CP behaviour

Was actually anybody else than snafle able to reproduce this behavior? (Now don't take me wrong, I want to get to the bottom of this, it's just that it sounds completely unbelievable for me - for instance my zsh actually *strips* the slashes from the end of directories when I press enter to execute a command like ls .. or cp ..).

And snafle: to check if it's mounted, just run 'mount' wink

Offline

#18 2008-04-28 00:08:53

Sigi
Member
From: Thurgau, Switzerland
Registered: 2005-09-22
Posts: 1,131

Re: File Deletion: or, Interesting CP behaviour

snafle wrote:

@sigi: It should make a difference, since I don't have write permissions anywhere other than my home dir? At least I thought that's how it worked.

If you have write permissions in a subfolder of /mnt depends on your settings in /etc/fstab. I'm quite sure someone already posted the answer to this whole thread: Could it be that the target of your copy command wasn't mounted by the time you tried to copy jarhead.mkv? You would end up with exactly this situation: /mnt/wherever/jarhead.mkv is there but all the files who have been in /mnt/wherever are gone. Isn't this your problem? Could you explain a little more detail about the medium and filesystem of the target?


Haven't been here in a while. Still rocking Arch. smile

Offline

#19 2008-04-28 16:25:23

snafle
Member
Registered: 2008-04-08
Posts: 41

Re: File Deletion: or, Interesting CP behaviour

My .bashrc is stock:

PS1='[\u@\h \W]\$ '

My video, music and backups folder are LVM partitions on a RAID 5'd disk- this is them in the fstab:

/dev/array/music        /mnt/music      jfs     defaults        0       0
/dev/array/video        /mnt/video      jfs     defaults        0       0
/dev/array/backups      /mnt/backups    jfs     defaults        0       0

Running mount gives me

[snafle@server ~]$ mount
/dev/md3 on / type jfs (rw)
none on /dev type ramfs (rw)
none on /proc type proc (rw)
none on /sys type sysfs (rw)
none on /proc/bus/usb type usbfs (rw)
none on /dev/pts type devpts (rw)
none on /dev/shm type tmpfs (rw)
/dev/md1 on /boot type ext2 (rw)
/dev/mapper/array-music on /mnt/music type jfs (rw)
/dev/mapper/array-video on /mnt/video type jfs (rw)
/dev/mapper/array-backups on /mnt/backups type jfs (rw)

I've noticed that if I run "ls" in the directory, it shows jarhead as a different colour to other things I just copied over from my desktop. Jarhead was encoded on the machine and copied into the folder. The other files are listed as green, jardhead in the standard putty color (greyish).

At the moment, I have jarhead, and a bunch of other video files (200gigs+) in the folder. The jarhead is the same one I copied into the folder that started this whole thing. I can access them to watch both over the network and on the server. The disc is mounted and all the files are on it.

Could I have got the syntax wrong, and made a new blank folder where Movies was?

Offline

#20 2008-04-28 17:02:02

dmartins
Member
Registered: 2006-09-23
Posts: 360

Re: File Deletion: or, Interesting CP behaviour

You've mentioned "movies" and "Movies". To linux, these are two different folders. Could this be the problem?

Offline

#21 2008-04-28 17:17:16

snafle
Member
Registered: 2008-04-08
Posts: 41

Re: File Deletion: or, Interesting CP behaviour

I'm pretty certain the lower case was just a typo on the transferal from screen to keys.. It's "Movies".

Last edited by snafle (2008-04-28 17:21:27)

Offline

#22 2008-04-28 17:27:55

snafle
Member
Registered: 2008-04-08
Posts: 41

Re: File Deletion: or, Interesting CP behaviour

I've edited my fstab to take into account what sigi said (letting me use it no-sudo'd). If anything, that's useful- thanks mate smile

Offline

#23 2008-04-29 08:47:17

moljac024
Member
From: Serbia
Registered: 2008-01-29
Posts: 2,676

Re: File Deletion: or, Interesting CP behaviour

Maybe jarhead is a folder where the rest of your movies went ? big_smile It's outrageous, I know....


The day Microsoft makes a product that doesn't suck, is the day they make a vacuum cleaner.
--------------------------------------------------------------------------------------------------------------
But if they tell you that I've lost my mind, maybe it's not gone just a little hard to find...

Offline

#24 2008-04-29 13:21:01

snafle
Member
Registered: 2008-04-08
Posts: 41

Re: File Deletion: or, Interesting CP behaviour

It's a video file, I can play it. It's about 1.13 gigs and loads in VLC.

Offline

Board footer

Powered by FluxBB