Home Directory Path

Screen Link:
Glob Patterns And Wildcards | Dataquest

DQ asks to move all files with names ending with ‘.b64’ to home directory.
The solution is as below. Please help in how the path was found.
I have lost my thought process doing bits of missions:

mv /sqlite-autoconf-3210000/tea/win/you_found_it.b64 ~

Hi @raturi22:

In a linux/Unix-based operating system, ~ represents the home directory or /home/<username>, which is somewhat similar to the Windows user profile (i.e. %UserProfile% can be translated to C:\Users\<username>.

To move all the file, you can use the wildcard * which means “all”. So the command would look something like this:

# find all files with .b64 extension from the root folder
find / -name *.b64        

 # moves the file returned into the home directory (since only 1 result is returned by the previous command)
mv /sqlite-autoconf-3210000/tea/win/you_found_it.b64 ~
1 Like

thanks . one query - what is the ~ at the end of mv command ?

@raturi22 if you were to google, the syntax for the mv command is:

mv [options] <source> <destination>

as described here. Since the home directory is what you wish to move the file to, you indicate it as the last argument at the end of the command.

In this case no options are needed since you are moving a single file. If you were moving a folder you would use -r which measns recursive (or move all files and subfolders within that folder itself)