• We did not send an email asking for donations - please read this post.

SOLVED: mv command with no destination?!?! omg it's gone?

LinuxLegends

New Member
Joined
Jul 18, 2022
Messages
13
Reaction score
1
Credits
135
So I was following a guide and the guy did a move command without a destination. I thought it made like a copy or something. But it had brackets at the end like this:

mv folders/file.key{,.bak}

now I can't find the file. even if I search by file extension like:

find . *.key

is the file deleted forever? where'd it move to?
 


OP
LinuxLegends

LinuxLegends

New Member
Joined
Jul 18, 2022
Messages
13
Reaction score
1
Credits
135
I did a search by .bak using the command osprey gave and it's still not showing up!

Also wouldn't a search by the name have it show up, even if it has a .key in the end?
In other words, if I do:
Code:
 find . goat
it would return a file named "goat.key.bak" right?
 

osprey

Active Member
Joined
Apr 15, 2022
Messages
286
Reaction score
193
Credits
2,625
Check the following code to see what the results are of the various commands. It's apparent that "file . goat" will show the file "goat.bak" in a listing but it only does so because it prints all the files in the directory it is looking in, and since the command is looking for "goat", it doesn't find that particular file and outputs "No such file or directory" for that file "goat". The more precise result that you would get in looking for the file with .bak in its name comes from the file command using the -name option as shown at the end of the code below.
Code:
[[email protected] ~]$ ls
file1  file2  file3  goat.bak

[[email protected] ~]$ find . goat
.
./file3
./file1
./file2
./goat.bak
find: ‘goat’: No such file or directory

[[email protected] ~]$ find . -name goat
[[email protected] ~]$ find . goat.bak

.
./file3
./file1
./file2
./goat.bak
goat.bak

[[email protected] ~]$ find . -name goat.bak
./goat.bak

[[email protected] ~]$ find . *.bak
.
./file3
./file1
./file2
./goat.bak
goat.bak
[[email protected]]$ find . -name *.bak
./goat.bak

As to the .bak file not showing up at all on your system, I can only speculate that it may have been inadvertently deleted or renamed with another filename. You could check all the files in the directory to see if such renaming has occurred.
 
OP
LinuxLegends

LinuxLegends

New Member
Joined
Jul 18, 2022
Messages
13
Reaction score
1
Credits
135
I realized the issue was once you add the dot to the find command, it only does that directory and not the sub directories!

Once I narrowed it down, the file showed up with the commands you suggested.
Is there a way to get the subs too?

*marked this as solved now
 
$100 Digital Ocean Credit
Get a free VM to test out Linux!

Linux.org Hosting Donations
Consider making a donation

Members online


Latest posts

Top