Permission denied when working with/without "su -c" in /cache I am trying to issue this command

adb shell "su -c echo 'boot-recovery' &gt; /cache/recovery/command"
//OR//
adb shell "echo 'boot-recovery' &gt; /cache/recovery/command"


outputs the same: /system/bin/sh: can't create /cache/recovery/command: Permission denied

I granted root permission for adb and i can run other commands with root normally like touch for example

I tried the command both ways when the file did and did not existed.

I tried checking for the existence of the file:

adb shell "if [ -f /cache/recovery/command ]; then echo "file found"; else echo "error"; fi"


it returned error even though the file does in fact exist

The Goal is to add a few lines to the recovery queue so the run the next time the device boots into recovery

Please correct me, I'm not so good at android command line, do I need to use a different command to achieve this goal?

More info: Android 8.1 (RR oreo) ... Magisk SU ... TWRP 3.2 (But need this to be compatible with as many android versions, recoveries, and su binaries as possbible .... I hope lol)
For me, this worked:

adb shell "su -c 'boot-recovery &gt; /cache/recovery/command'"


You start with a double quote before su -c. Then single quote for the command, a single quote after the command and close with a double quote.