I am a beginner with Ubuntu and I tried searching for an answer for this but I can't find one that covers this and I am confused by the output I am getting. I know you can use cp to copy to a parent directory by using .. or copy to your current with ., but I was trying to copy to my previous directory using - and I am getting a weird result.
cp testfile1.ogg -
This doesn't copy the file testfile1.ogg to my previous directory. It creates a file called - in my current directory. If I try
cp testfile1.ogg ..
then this copies testfile1.ogg to the parent directory. Why does using the - shortcut not work?
$OLDPWD
environment variable thatbash
sets for you.-
is not a shortcut for "previous directory", it is often used forSTDOUT
, but that's a per-command choice, check theman
page for the command. – waltinator Sep 16 '23 at 16:31-
– muru Sep 16 '23 at 22:19