从 unix 机器上的目录中删除 ~$filename.docx 文件
Remove ~$filename.docx files from directory on unix machine
我正在尝试从我的 unix 机器的目录中删除以下文件:
$ ls -la
total 160
... other files ...
-rw-r--r--@ 1 username staff 171 Oct 24 2017 ~$checklist.xlsx
-rw-r--r--@ 1 username staff 171 Oct 16 2017 ~$papers.xlsx
-rw-r--r--@ 1 username staff 162 Sep 4 2017 ~$rec.docx
-rw-r--r--@ 1 username staff 162 Nov 25 21:00 ~$file1.docx
-rw-r--r--@ 1 username staff 162 Nov 25 21:01 ~$file2.docx
但是,当我尝试删除它们时,由于各种原因它不让我删除。例如:
$ rm ~$checklist.xlsx
rm: ~.xlsx: No such file or directory
$ rm $checklist.xlsx
rm: .xlsx: No such file or directory
$ rm checklist.xlsx
rm: checklist.xlsx: No such file or directory
为什么我的电脑不让我删除这些文件?我怎样才能删除它们?谢谢!
你需要对这些字符进行转义
创建一个的简单方法:
echo "fileteste" > \~$file
删除一个的简单方法:
rm \~$file
我正在尝试从我的 unix 机器的目录中删除以下文件:
$ ls -la
total 160
... other files ...
-rw-r--r--@ 1 username staff 171 Oct 24 2017 ~$checklist.xlsx
-rw-r--r--@ 1 username staff 171 Oct 16 2017 ~$papers.xlsx
-rw-r--r--@ 1 username staff 162 Sep 4 2017 ~$rec.docx
-rw-r--r--@ 1 username staff 162 Nov 25 21:00 ~$file1.docx
-rw-r--r--@ 1 username staff 162 Nov 25 21:01 ~$file2.docx
但是,当我尝试删除它们时,由于各种原因它不让我删除。例如:
$ rm ~$checklist.xlsx
rm: ~.xlsx: No such file or directory
$ rm $checklist.xlsx
rm: .xlsx: No such file or directory
$ rm checklist.xlsx
rm: checklist.xlsx: No such file or directory
为什么我的电脑不让我删除这些文件?我怎样才能删除它们?谢谢!
你需要对这些字符进行转义
创建一个的简单方法:
echo "fileteste" > \~$file
删除一个的简单方法:
rm \~$file