In your script you forgot #
, and what is more the command to delete is not delete
(as you wrote) but rm
, along with at least one option:
-r
for recursive
-f
for force
-v
for verbose
so try
For a single file
#!/system/bin/sh
rm /path/to/file/filename.extension
For a group of files @ location by extension with wildcard:
#!/system/bin/sh
rm /path/to/file/*.extension
A straight up clearing of a directory:
#!/system/bin/sh
rm /path/to/directory-containing-files/*
Alternate to clear that directory of files and directories as well, with verbose to see what's being deleted
#!/system/bin/sh
rm -frv /path/to/file/*
To delete the directory itself
#!/system/bin/sh
rm -fr /kill/that/pesky/directory
You must have root
privileges to modify anything in /system
and/or /data
folder.
The exception would be /data/local
directory which you should be able to access/modify within as peon user.
If selinux
is enforcing you will NOT be able to modify anything in /data
with the exception of the previously stated exception even if su
.
This with the exception of laying out the proper path to sh
in your script is not really an android question.
Your normal practices in scripting on a Linux OS should mostly carry over as long as you use the correct path to sh
.
You can create that script in regular sdcard
storage space and execute by running
su
/sdcard/./yams.sh
I like yams. They're nummy.
If you get a permission error, denied etc., then
chmod 755 /path/to/script.sh
and again run as su
You can alternately run
su -c /sdcard/yams.sh
chmod 755 test.sh
after copying it to the phone? – Manu Dec 28 '15 at 04:05/
directory and there is noAndroid
directory at first level of/
. – Firelord Dec 28 '15 at 15:47