You are not logged in.

#1 2012-06-08 14:36:30

roguewolf
Member
From: UK
Registered: 2012-05-28
Posts: 32

[SOLVED] Moved File to ..\ instead f ../ - Where Would It Have Gone?

Newbie error, moved a file to ..\ instead of ../ by mistake (my fingers must have drifted back into Windows mode for a second, damn them!)

Could anyone tell me where the file will be (if it hasn't been destroyed, of course) please?

Man thanks.

Last edited by roguewolf (2012-06-08 16:28:13)

Offline

#2 2012-06-08 14:40:58

Pres
Member
Registered: 2011-09-12
Posts: 423

Re: [SOLVED] Moved File to ..\ instead f ../ - Where Would It Have Gone?

What is the exact command you typed? "mv FILE ..\"?

The backslash will just continue the command on a second line. If you pressed enter after that, it should have executed this command:

mv FILE ..

Which would be the exact same as what you were trying to do...

Offline

#3 2012-06-08 14:42:29

alphaniner
Member
From: Ancapistan
Registered: 2010-07-12
Posts: 2,810

Re: [SOLVED] Moved File to ..\ instead f ../ - Where Would It Have Gone?

$ touch file
$ mv file ..\
> 
‘file’ -> ‘../file’

The \ allows a line break in a command.  Since I didn't enter anything after the line break, the command was effectively mv file .. and the file was moved to the parent dir.


But whether the Constitution really be one thing, or another, this much is certain - that it has either authorized such a government as we have had, or has been powerless to prevent it. In either case, it is unfit to exist.
-Lysander Spooner

Offline

#4 2012-06-08 14:47:02

WorMzy
Forum Moderator
From: Scotland
Registered: 2010-06-16
Posts: 11,939
Website

Re: [SOLVED] Moved File to ..\ instead f ../ - Where Would It Have Gone?

In most shells (if not all) a "\" is used as an escape character. So

mv file ..\
<enter>

won't actually execute anything, it'll just move your prompt down a line, then wait for more input.

If you actually did

mv file ..\
<enter><enter>

then that's the same as just doing "mv file ..", and the file will be in the parent directory of the directory you were in.

If, however, what you did was:

mv file ..\\
<enter>

Then the file will now actually be called "..\".

mv ..\\ file

Will rename the file in this case.


Sakura:-
Mobo: MSI MAG X570S TORPEDO MAX // Processor: AMD Ryzen 9 5950X @4.9GHz // GFX: AMD Radeon RX 5700 XT // RAM: 32GB (4x 8GB) Corsair DDR4 (@ 3000MHz) // Storage: 1x 3TB HDD, 6x 1TB SSD, 2x 120GB SSD, 1x 275GB M2 SSD

Making lemonade from lemons since 2015.

Offline

#5 2012-06-08 16:10:00

roguewolf
Member
From: UK
Registered: 2012-05-28
Posts: 32

Re: [SOLVED] Moved File to ..\ instead f ../ - Where Would It Have Gone?

Thanks for all the quick replies smile

Looking through my history, the command I entered was:

mv myfile.txt ..\myfile.txt

I can't remember if I pressed enter afterwards (although the next command in my history is 'ls') but the file is no longer in its original location and it isn't in the directory above either.  I can't use 'whereis' or 'locate' because the location is a mounted NAS share.

Offline

#6 2012-06-08 16:14:03

roguewolf
Member
From: UK
Registered: 2012-05-28
Posts: 32

Re: [SOLVED] Moved File to ..\ instead f ../ - Where Would It Have Gone?

Now that's strange. the file has been renamed

..myfile.txt

hmm

Offline

#7 2012-06-08 16:15:17

Pres
Member
Registered: 2011-09-12
Posts: 423

Re: [SOLVED] Moved File to ..\ instead f ../ - Where Would It Have Gone?

It's hidden now with the name ..myfile.txt.

Edit: Beat me to it.

Last edited by Pres (2012-06-08 16:15:35)

Offline

#8 2012-06-08 16:16:41

roguewolf
Member
From: UK
Registered: 2012-05-28
Posts: 32

Re: [SOLVED] Moved File to ..\ instead f ../ - Where Would It Have Gone?

@Pres Only just though!  Is that because the backslash was treated as an escape character rather than a line-continuation?

Offline

#9 2012-06-08 16:19:50

roguewolf
Member
From: UK
Registered: 2012-05-28
Posts: 32

Re: [SOLVED] Moved File to ..\ instead f ../ - Where Would It Have Gone?

@all

Please accept my apologies for the incomplete code in my original question.  Missing off the full destination path made it somewhat misleading!

Offline

#10 2012-06-08 22:00:59

DSpider
Member
From: Romania
Registered: 2009-08-23
Posts: 2,273

Re: [SOLVED] Moved File to ..\ instead f ../ - Where Would It Have Gone?

roguewolf wrote:

Is that because the backslash was treated as an escape character rather than a line-continuation?


It's hidden because it has a dot in front of it. Any file that starts with a dot will be hidden on Linux (by default).


"How to Succeed with Linux"

I have made a personal commitment not to reply in topics that start with a lowercase letter. Proper grammar and punctuation is a sign of respect, and if you do not show any, you will NOT receive any help (at least not from me).

Offline

#11 2012-06-09 08:03:20

roguewolf
Member
From: UK
Registered: 2012-05-28
Posts: 32

Re: [SOLVED] Moved File to ..\ instead f ../ - Where Would It Have Gone?

Thanks DSpider, I knew about dotfiles being hidden (really kicked myself when I remembered to add the -a switch to ls and found the file!) but was curious as to why the backslash was not treated as a line-break.

I know the backslash can be used to indicate a literal character in some cases (e.g RegEx) so I wonder if it just caused the 'm' in 'myfile' to be treated literally (exactly as it would have without the backslash).

Offline

#12 2012-06-09 12:47:19

Pres
Member
Registered: 2011-09-12
Posts: 423

Re: [SOLVED] Moved File to ..\ instead f ../ - Where Would It Have Gone?

Yes. The backslash just says "preserve the literal value of the next character" which in this case was the m. The exception to this is if the next character is a newline character, in which case it tells bash to ignore it.

Offline

Board footer

Powered by FluxBB