Linux Next interesting question (the file name begins with a dash or a space)

Source: Internet
Author: User

Linux Next interesting question (the file name begins with a dash)

This was an inadvertent discovery.

Under Linux, the file name contains - There is no problem, but if the file name is - as the first character, then it is more troublesome.

Problem Demo

Look here, the filename beginning with the dash appears to be immune to operations such as MV CP RM . With this feature you can create some cumbersome files or folders.

[Email protected]:~$ls-Python.md[email protected]-pc:~$MV-python.md5-python.mdMV: Invalid option--Ptry'MV--help'  for  Moreinformation. [Email protected]-pc:~$MV "-python.md" 5-python.mdMV: Invalid option--Ptry'MV--help'  for  MoreInformation.

Solutions

This is actually a good solution, the problem is because it will - as an option parameter identification, and cause the corresponding file cannot be found. The solution is to find a way to hide this.

MV 5-pythom.md

File name begins with a space

There is no intention to say too much here, the principle is the same. If the file name begins with a space, you must know the number of spaces.

Enclose the file name you want to manipulate in single quotation marks

For example, there is a file named "a" Note that the file name is three spaces plus one letter A. If you rename it, use the following command

mv '   A'    new file name

Linux Next interesting question (the file name begins with a dash or a space)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.