adb command fail to execute if path contain spaces

孤人 提交于 2019-12-20 02:34:04

问题


I am trying to delete the file using adb command. But the file contain spaces. So adb command throws an error after reading half of the file name till space. Is there a way to overcome this issue. I am executing following adb command

When I execute

adb shell rm /sdcard/samsung_Nexus S_converter.xml

Error message: rm failed for /sdcard/samsung_Nexus, No such file or directory

How ever when I execute:

adb shell rm /sdcard/samsung_Nexus_S_converter.xml

File deletion is successful

I searched for solution for this, if there is any workaround. How ever I couldnt find any.


回答1:


Since you are using command line, you need to know that spaces must be escaped by using (backslash before the special character like "space"), so, in your case this should work too:

adb shell rm /sdcard/samsung_Nexus\ S_converter.xml

Hope it helps!

Regards!




回答2:


By me it wasn't enough to escape spaces with backslashes:

$ adb shell ls /storage/sdcard1/audio/Die\ Toten\ Hosen/
/storage/sdcard1/audio/Die: No such file or directory
Toten: No such file or directory
Hosen/: No such file or directory        

For some reason I also had to surround the path with '':

$ adb shell ls '/storage/sdcard1/audio/Die\ Toten\ Hosen/'                                                                                                                       
03 - Boxed Set                                                                                                                                                                                                     
04 - Compilations                                                                                                                                                                                                  
05 - Live Albums                             

While surrounding without escaping didn't work:

$ adb shell ls '/storage/sdcard1/audio/Die Toten Hosen'                                                                                                                       
/storage/sdcard1/audio/Die: No such file or directory                                                                                                                                                              
Toten: No such file or directory                                                                                                                                                                                   
Hosen: No such file or directory      



回答3:


Did you tried escaping the space

adb shell rm /sdcard/samsung_Nexus\ S_converter.xml



来源:https://stackoverflow.com/questions/24683077/adb-command-fail-to-execute-if-path-contain-spaces

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!