Linux / UNIX : Move File Starting With A Dash

Linux / UNIX : Move File Starting With A Dash

In Linux or Unix, the dash (-) character is often used to specify options for command-line tools. As a result, files that start with a dash (-) can be difficult to work with, as the dash may be interpreted as an option rather than a part of the file name.

To move a file that starts with a dash (-) using the mv command, you can use one of the following options:

  1. Use the ./ prefix: By adding the ./ prefix to the file name, you can specify that the file is in the current directory. For example:
mv ./filename destination
Source:w‮‬ww.lautturi.com
  1. Use the -- option: The -- option tells the mv command to stop processing options and treat everything that follows as a file name. For example:
mv -- filename destination
  1. Use the absolute file path: You can also specify the absolute file path to the file, rather than the file name itself. For example:
mv /path/to/filename destination

By using one of these options, you can move a file that starts with a dash (-) using the mv command in Linux or Unix.

Note: If you are using a file manager to move the file, you may be able to simply drag and drop the file to the destination folder without using any special options.

Created Time:2017-10-29 22:08:55  Author:lautturi