How to open a directory with spaces or special symbols with a Linux terminal directive

Source: Internet
Author: User

Use terminal to specify open folder under Linux, the directory name contains syntax errors, there are two choices:
1, according to the Linux recommended file naming specification, to modify the folder name;
2, use the escape character \;
3, in pairs using double quotation marks "";

Introduction to Linux file naming conventions

 The Linux system distinguishes the case of English characters. The rules for naming directories and naming files are the same. User-created file and directory names use lowercase characters unless there is a specific reason to do so. Most Linux commands also use lowercase characters. The file names under the Linux system can be up to 256 characters long. Typically, the characters of a file name include: Letters, Numbers, "." (dots), "_" (underscore), and "-" (hyphens). Linux allows the use of symbols other than the above symbols in the file name, but it is not recommended for users to do so.

You can use long filenames and directory names under Linux, and you can give them any name, but you must follow these rules:

☆ except/Outside, all the characters can be;
☆ Some characters are best not used, such as space character, tab, backspace and the following characters:? @ # $ & () \ | "" "and so on (where the/number has been strictly forbidden in the first article, () is the English brackets);

☆ Avoid using +-or. The first character as a normal file name (files that begin with. Start in Linux are hidden files);

☆ and Windows file naming is not the same, under Linux file name case sensitive.

☆ In addition, try to avoid the use of Chinese and Chinese symbols;

Use the escape character \

 Although it is possible to avoid using special symbols in filenames, you can still read them using escape characters if you encounter such a situation.

The characters that can be escaped include: "?" (question mark), "*" (asterisk), "" (Space), "$" (currency symbol), "&" (logical character), "()" (English brackets), and so on.

  For example, open the Adobe folder under Program Files (x86):

1 $ cd Program\ Files\ \(x86\)/Adobe

paired with double quotation marks "" (Recommended this method)

 When opening a directory using directives in a terminal, it is okay to use double quotation marks to keep the original path, and to include the illegal characters in a timely path. There are two ways to use it:

1. Enclose the entire path in a pair of double quotes

For example, open the ~/.wine/drive_c/program Files (x86)/adobe/adobe Photoshop CS6 folder:

1 $ cd "~/.wine/drive_c/Program Files (x86)/Adobe/Adobe Photoshop CS6"
This method is most convenient to use, so it is highly recommended, so you can safely paste the path within quotation marks and open the directory normally.

2. Enclose a fragment of a segment with illegal characters in double quotation marks

For example, open the program Files (x86) Folder:

1 $ cd Program" Files (x86)"

This method is very flexible, the use of double quotation marks Unlimited, as long as the appearance of the pair, the terminal will quote the contents of the full receipt.

For example, open the program Files (x86)/adobe/adobe Photoshop CS6 folder, which you can also :

1 $ cd Pro"gram Fi"les" (x86)/Adobe""/Adobe "Photo"shop C"S6

This instruction uses 4 double quotation marks intermittently, or uninterrupted, so that all spaces and parentheses are enclosed in double quotation marks, and the folder opens normally.

How to open a directory with spaces or special symbols with a Linux terminal directive

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.