How Linux moves a copy deletes a file with a special literal character prefix (-,--,;)

Source: Internet
Author: User
Tags touch command

In Linux systems, many metacharacters, such as semicolons (semicolon), spaces (space), backslashes (backslash), dollar signs (dollar sigh), question marks (question mark), and asterisks (asterisk) are often interpreted as commands ,-(dashes) or--the option to be interpreted as a command, you can copy, move, delete a band-or--file in the following ways:


1. First, create a file, create a prefix band-or--the file cannot be directly used by the touch command because it will be interpreted as an option for the command, so it has to be created in an append form:

[[email protected] tmp]# echo >-foo.txt[[email protected] tmp]# echo >-bar.txt


After creating the file, if you use the LS command to list the file by using the wildcard character, the following error will appear:

[Email protected] tmp]# ls-l *.txtls:invalid option--'. ' Try ' ls--help ' for more information.

You need to include the-delimiter option in the command, separating the options and parameters:

[Email protected] tmp]# ls-l--*.txt-rw-r--r--. 1 root root 2192022 Jan 9 09:03 137k.txt-rw-r--r--. 1 root root 1 Jan 9 16:36-bar.txt-rw-r--r--. 1 root root 1 Jan 9 16:36-foo.txt

corresponding, the command to copy and move the file is used as follows:

[email protected] tmp]# CP---foo.txt/opt/
[Email protected] tmp]# MV---bar.txt/opt/

This delimiter is also valid for the Rmdir,rm,ls command.

This article is from the "Ordinary Road" blog, please be sure to keep this source http://linjohn.blog.51cto.com/1026193/1601288

How Linux moves a copy deletes a file with a special literal character prefix (-,--,;)

Related Article

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.