Misplaced files


Exilepc

Recommended Posts

I was moving 3 tb of files to a new dir, the putty screen was acting up and sent this command "mv /mnt/user/Downloading/downloaded// /mnt/user/TV/*.*" the issue is the double // after /mnt/user/Downloading/downloaded

 

I am looking for the files.... any help would be great

Edited by Exilepc
Link to comment

Never use an argument with * or ? as last argument to mv or cp.

 

The wild card characters will be expanded into the individual matching names - so your single last argument could be supplied as many arguments to mv. And mv will then use the last name of that expansion as the actual target, while all the other names from that expansion will be seen as additional source names.

 

An example:

pwm@iapetus:~/mv-test$ mkdir s1 s2 s3
pwm@iapetus:~/mv-test$ mkdir t1 t2 t3
pwm@iapetus:~/mv-test$ mv s* t*
pwm@iapetus:~/mv-test$ ls -lrt
total 4
drwxr-xr-x 7 pwm pwm 4096 Jan 24 22:00 t3
pwm@iapetus:~/mv-test$ ls -l t3
total 20
drwxr-xr-x 2 pwm pwm 4096 Jan 24 22:00 s1
drwxr-xr-x 2 pwm pwm 4096 Jan 24 22:00 s2
drwxr-xr-x 2 pwm pwm 4096 Jan 24 22:00 s3
drwxr-xr-x 2 pwm pwm 4096 Jan 24 22:00 t1
drwxr-xr-x 2 pwm pwm 4096 Jan 24 22:00 t2

Notice what happened when the second argument t* got expanded, making mv run as if it had seen the following command:

mv s1 s2 s3 t1 t2 t3

So it assumed that s1, s2, s3, t1 and t2 all should be moved into the directory t3.

Which is not obvious from the command:

mv s* t*

 

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.