我该如何grep某个在文件名开头以空格开头的文件,然后重新命名而不带空格?顺便说一下,还有其他文件包含“ file1名称”。ls-“ File1”将显示所有名称为“ File1”的文件。
$ls -l
drwxr-xr-x 2 root root 1515 Apr 8 01:36 File1
drwxr-xr-x 2 root root 1515 Apr 8 01:49 File1
drwxr-xr-x 2 root root 2343 Apr 8 01:54 File3
drwxr-xr-x 2 root root 2303 Apr 8 01:59 File4
drwxr-xr-x 2 root root 2303 Apr 8 01:59 Another_File1
如您所见,“ File1”的开头有一个空格。如何将“ File1”重命名为“ Bad_File1”?
谢谢
只需引用其名称:
mv " File1" "Bad_File1"
^
另请注意,“ File1”是一个目录:
drwxr-xr-x 2 root root 1515 Apr 8 01:36 File1
^
所以您所看到的ls -l " File1"
就是该目录的内容。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句