我尝试了不同的转义方法,但仍然无法删除名称中带有空格和“与”号的文件。
[23:36 @ ~] $ rm /Volumes/Storage/Music/pop/Nicole\ Kidman\ \&\ Ewan\ Mcgregor\ -\ Come\ What\ May.mp3
[23:36 @ ~] $ rm /Volumes/Storage/Music/pop/Nicole\ Kidman\ \\&\ Ewan\ Mcgregor\ -\ Come\ What\ May.mp3
[23:36 @ ~] $ rm /Volumes/Storage/Music/pop/Nicole\ Kidman\ &\ Ewan\ Mcgregor\ -\ Come\ What\ May.mp3
[23:36 @ ~] $ rm /Volumes/Storage/Music/pop/Nicole\ Kidman\\ &\ Ewan\ Mcgregor\ -\ Come\ What\ May.mp3
[23:36 @ ~] $ rm /Volumes/Storage/Music/pop/Nicole\ Kidman\\ & Ewan\ Mcgregor\ -\ Come\ What\ May.mp3
[23:38 @ ~] $ rm "/Volumes/Storage/Music/pop/Nicole Kidman & Ewan Mcgregor - Come What May.mp3"
[23:38 @ ~] $ rm "/Volumes/Storage/Music/pop/Nicole Kidman \& Ewan Mcgregor - Come What May.mp3"
自动完成
带单引号
操作系统:Mavericks 1.9.0
编辑:
我不知道为什么,但是当你使用/bin/rm
而不是 时,rm
它可以正常工作,即使rm
指向/bin/rm
。 (这真的很奇怪)
[01:32 @ ~/test] $ which rm
/bin/rm
[01:32 @ ~/test] $ rm Nicole\ Kidman\ \&\ Ewan\ Mcgregor\ -\ Come\ What\ May.mp3
[1] 10930
-bash: Ewan Mcgregor - Come What May.mp3: command not found
rm: Nicole Kidman : No such file or directory
[1]+ Exit 1 /bin/rm Nicole\ Kidman\
[01:32 @ ~/test] $ /bin/rm Nicole\ Kidman\ \&\ Ewan\ Mcgregor\ -\ Come\ What\ May.mp3
答案1
尝试/bin/rm
而不只是rm
。我怀疑你为它设置了一个别名,rm
这会妨碍你。