5

I was wondering if there was a cleaner method to move files into the current directory than this:

mv path/to/file ../current_directory

If I wanted to move a file to the directory above I could go:

mv file ..

Is there a way to represent the current directory?

muru
  • 197,895
  • 55
  • 485
  • 740
macourtney7
  • 2,817

2 Answers2

4

The current directory is ., so you can use:

mv path/to/file .
Chai T. Rex
  • 5,193
0

"PWD" is the environment variable for current directory. So, you can do :

mv path/to/file $PWD/

You can test this yourself, for example :

cd /tmp
touch test-file.txt
mkdir /tmp/test-dir
cd test-dir
echo $PWD
mv /tmp/test-file.txt $PWD/
ls -la $PWD/
albert j
  • 1,453