Directory changed to file name
hello, i am new to linux and i dont know what i did.
i had a very important directory called public_html for my website i was moving a file to my /home/user21/public_html/ directory with this command: mv mybackup.sql /home/user*/pub*/mybackup.sql so when i cd to the /home/user21/public_html/ it said "no such directory" so when i do a list it shows the public_html as a file? Code:
-rw-r--r-- 1 root root 44966003 2012-01-01 17:26 public_html can anyone help me please. how can i change it back to a directory? thank you |
You basically just renamed your mybackup.sql to public_html. You probably shouldn't be using wildcards in your mv command.
Just rename back your file with mv. |
oh i see. ok.
so if i rename public_html to mybackup.sql Code:
mv public_html mybackup.sql im scared to even ask this.. what happened to the original public_html, directory is it gone? anyway i can get it back? |
Yes. Your mv command will restore mybackup.sql
As for your folder.. I've never used wildcards in a command like this, I'm not sure what it will do. I'm inclined to believe that the public_html folder did not exist in that location in the 1st place, otherwise it would not have renamed the file like it did. |
Quote:
|
The shell expands wildcards (globs) into the complete list of matching files before it executes the command. So the actual command that the shell ran was something like this:
Code:
mv mybackup.sql /home/user1/pub1/mybackup.sql /home/user1/pub2/mybackup.sql /home/user2/pub1/mybackup.sql ... ... /home/user100/pub100/mybackup.sql Depending on how the final command is formatted, you can end up overwriting files of the same name, or moving whole directory trees to other places. A safer way to use mv in cases like this is to explicitly name the target directory with the -t option. Code:
mv -t targetdir mybackup.sql |
yes, i agree. i took a gamble using the wild card. i will remember that next time not to be tempted to use it. for the last couple of day i have been on that shell sending command after command trying to see what i did wrong. i prayed that i can get this data back. it was 5.3G worth of files.. i review my history. used the find command and the fgrep command to see where i can find it. FINALLY. i found something strange. i looked for all the public_html files in the whole file system and i found one that caught my eye. i dont know what i did, but i guess i moved the public_html directory to another public_html directory because thats where i found it. it was amazing when i saw all those files back. I kneel down and thanked that Lord Jesus for getting back this data. Thank you "ongte", "MTK358" and "David the H." for your advise. i will use the wild card more carefully next time.
|
All times are GMT -5. The time now is 07:36 PM. |