You are not logged in.
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
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
$ 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
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
Thanks for all the quick replies
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
Now that's strange. the file has been renamed
..myfile.txt
Offline
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
@Pres Only just though! Is that because the backslash was treated as an escape character rather than a line-continuation?
Offline
@all
Please accept my apologies for the incomplete code in my original question. Missing off the full destination path made it somewhat misleading!
Offline
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).
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
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
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