Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

adb command fail to execute if path contain spaces

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.

like image 315
Venkatesh Avatar asked Dec 19 '22 13:12

Venkatesh


2 Answers

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!

like image 200
Martin Cazares Avatar answered Jan 10 '23 00:01

Martin Cazares


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 ' (single quotation):

$ 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      
like image 28
ka3ak Avatar answered Jan 10 '23 00:01

ka3ak