Linux如何移動複製刪除帶特殊文字元首碼(-,--,;)的的檔案

來源:互聯網
上載者:User

標籤:--   linux如何移動複製刪除帶特殊文字元首碼()-   ;的的檔案   

  在linux系統中,許多元字元,如分號(semicolon),空格(space),反斜線(backslash),貨幣符號(dollar sigh),問號(question mark),星號(asterisk) 通常被解釋為命令,-(dashes)或者--被解釋為命令的選項,通過以下的方式就可以複製、移動、刪除帶-或者--的檔案,:


1、首先,建立檔案,建立首碼帶-或--檔案不能直接使用touch命令,因為會被解釋為命令的選項,所以得用追加的形式建立:

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


 建立檔案後,如果使用ls命令嘗試萬用字元的方式列出檔案,則會出現以下報錯:

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

需要在命令加入--分界符選項,分隔開選項和參數:

[[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

 相對應的,複製與移動檔案的命令使用如下:

[[email protected] tmp]# cp -- -foo.txt /opt/
[[email protected] tmp]# mv -- -bar.txt /opt/

    這個分隔字元對於rmdir,rm,ls命令同樣有效。

本文出自 “平凡之路” 部落格,請務必保留此出處http://linjohn.blog.51cto.com/1026193/1601288

Linux如何移動複製刪除帶特殊文字元首碼(-,--,;)的的檔案

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.