Today, I found another use of current directory — single dot .. Before, I occasionally use it with mv or cp commands like
# copying file to current directory from somewhere else cp /path/to/foo . # moving a file in sub-directory to current directory mv subdir/bar .
The usage is:
cd .
Changing to current directory may not make sense without context. I have an encrypted directory, say ~/secret/ here, which is encrypted and mounted by EncFS. Quite often I forget to mount first before change to ~/secret, so it will be just an empty directory. When that happen I move up one directory and mount the encrypted directory with a helper script I wrote, then cd into the directory again.
That is okay, but really unnecessary. Now, I can just run
cd ~/secret ls # shoot! forgot to mount first script-to-mount cd .
Voilà, the encrypted files are there. . alone is quite useful sometimes, however it’s still not used in many cases and cd . probably is only useful in this case.
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.