Use the Bash command under Linux to perform directory considerations with "(" symbol) in the name

Source: Internet
Author: User
Tags mkdir zip

*********************************************** Statement ************************************************

Original works, from the "Blue Blog" blog, Welcome to reprint, please be sure to indicate the source, otherwise the legal liability for copyright.

There is a mistake in the statement, please leave a message or mail (hyldba@163.com) specified, be grateful.

This reprint must be retained here: http://blog.csdn.net/huangyanlong/article/details/39214295

Blue Blog:http://blog.csdn.net/huangyanlong.

  ****************************************************************************************************

1. Inadvertent discovery: The escape of the "(" symbol)

The name with the "(" Symbol of the directory, the Linux system is not directly to perform operations on it, if you want to operate directly, you need to add an escape character in the name, the following examples

[Root@hyldb soft]# LS--view file, found an RPM (CentOS5.6 +11g) directory

New P13390677_112040_linux-x86-64_2of7.zip

P13390677_112040_linux-x86-64_1of7.zip rpm (CentOS5.6 +11g)

[Root@hyldb soft]# cd rpm (CentOS5.6 +11g)--Go directly to the directory, prompting for errors

-bash:syntax error near unexpected token ' ('

[Root@hyldb soft]# cd rpm/(centos5.6/+11g/)--After changing the format, enter the successful

[Root@hyldb rpm (CentOS5.6 +11g)]#

If you want to delete an operation, you also need to add an escape character, as shown in the following example:

[Root@hyldb soft]# rm-rf rpm/(centos5.6/+11g/)/

2. Escape of Space: space handling in Escape

Note that if you create a directory with a similar "+" symbol that is connected to a space, you need to add the escape character "/" before its "space", or it will be split into multiple directories, for example:

Create a table of contents without spaces: (1+2)

[Root@hyldb soft]# mkdir/(1+2/)

[Root@hyldb soft]# ls--View Discovery Directory Creation success

(1+2) New P13390677_112040_linux-x86-64_1of7.zip P13390677_112040_linux-x86-64_2of7.zip

Create a table of contents with spaces: (1 + 2)

[Root@hyldb soft]# mkdir/(1 + 2/)

[Root@hyldb soft]# ls--view discovery, because the format is not noticed, the default created three directories, respectively: "+", "(1", "2)" These three directories

+ (1+2) New P13390677_112040_linux-x86-64_2of7.zip

(1 2) P13390677_112040_linux-x86-64_1of7.zip

The proper format for creating a "(1 + 2)" Directory should be the following:

[Root@hyldb soft]# mkdir/(1/+/2/)

[Root@hyldb soft]# ls--View Discovery, "(1 + 2)" Directory created successfully

(1 + 2) New P13390677_112040_linux-x86-64_1of7.zip P13390677_112040_linux-x86-64_2of7.zip

  Summary: If there are spaces in the directory name, you need to escape the spaces individually, or they will be split into a single directory

3. PostScript: Delete the experimental catalogue

[Root@hyldb soft]# ls

+ (1 + 2) New

(1 (1+2) p13390677_112040_linux-x86-64_1of7.zip

(1 + 2) p13390677_112040_linux-x86-64_2of7.zip

[Root@hyldb soft]# RM-RF +/(1/+/2/)/(1/(1/+ 2/)

[Root@hyldb soft]# ls

(1+2) New P13390677_112040_linux-x86-64_1of7.zip P13390677_112040_linux-x86-64_2of7.zip

[Root@hyldb soft]# RM-RF/(1+2/)

[Root@hyldb soft]# ls

New P13390677_112040_linux-x86-64_1of7.zip P13390677_112040_linux-x86-64_2of7.zip

Small details, Jane and the Mind

  Statement ************************************************

Original works, from the "Blue Blog" blog, Welcome to reprint, please be sure to indicate the source, otherwise the legal liability for copyright.

There is a mistake in the statement, please leave a message or mail (hyldba@163.com) specified, be grateful.

This reprint must be retained here: http://blog.csdn.net/huangyanlong/article/details/39214295

Blue Blog:http://blog.csdn.net/huangyanlong.

  ****************************************************************************************************

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.