Get the App
SLTechnology News&Howtos  ›  Development  › 

How to deal with the occurrence of special characters in the linux command that cannot pass parameters

Shulou Source: shulou.com Published: 2022-06-02 01:05:50 10月02日 Update

In this article Xiaobian for you to introduce in detail the "linux command in the special characters can not be passed parameters how to deal with", detailed content, clear steps, details handled properly, I hope that this "linux commands in the special characters can not be passed parameters how to deal with" article can help you solve doubts, the following with the editor's ideas slowly in-depth, together to learn new knowledge.

Command line special character processing method

The special symbols in the linux command include: *,\, $, [,], +, -, &,%, #,!, ~, `, spaces, etc., which have a special meaning. You should pay attention to the use of these symbols on the command line, otherwise you will report an error.

For example, I have a directory here: the name of the directory has a space in the middle (aa bb is a directory, not two, but with a space in the middle):

When we want to delete him, we will report an error if we delete him directly. Rm will think that there are two directories:

Method 1: draw him up as follows

Method 2: escape\:

The same is true of other commands:

The above is just a simple example. All linux commands can deal with special characters in this way. I think it is easier to use quotation marks:

The following is a problem encountered by a group member on the QQ group in our lecture hall: the perl script has many parameters, and there are many special characters in the parameter values, so that linux can not distinguish which is the parameter name and which is the parameter value, which leads to an error:

The solution is to quote the entire parameter value (all the contents of the red box are caused), rather than simply introducing the pacid:

After reading this, the article "how to deal with the parameters that cannot be passed in special characters in linux commands" has been introduced. If you want to master the knowledge points of this article, you still need to practice and use it yourself to understand it. If you want to know more about related articles, welcome to follow the industry information channel.

Tags: Special parameters commands characters processing methods directories contents articles two examples just spaces symbols will report proper convenient method name meaning Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Apple NVidia OPPO Reno MySQL Huawei