I always disbale all the IOSTAT in my android's memory IOBLOCKS and just wanted to make this code into a fewer lines
Is it possible:
#!/system/bin/sh
echo 0 > /sys/block/sda/queue/iostats
echo 0 > /sys/block/sdb/queue/iostats
echo 0 > /sys/block/sdc/queue/iostats
echo 0 > /sys/block/sde/queue/iostats
echo 0 > /sys/block/sdf/queue/iostats
echo 0 > /sys/block/sdd/queue/iostats
CodePudding user response:
#! /system/bin/sh -
echo 0 | tee /sys/block/sd[a-f]/queue/iostats
CodePudding user response:
One liner, chopped to few lines so it's easier to read:
#!/system/bin/sh
for z in a b c d e f;do
echo 0 > /sys/block/sd${z}/queue/iostats
done
This solution uses only echo
, and no other apps like tee
, awk
, grep
...
via Bash it can be even shorter with: {a..f}
, but I see you want/need to use sh
CodePudding user response:
grep -o . <<<abcdef|awk '{ print "echo 0 > /sys/block/sd"$1"/queue/iostats"}'|sh
CodePudding user response:
Wild card should work:
echo 0 > "/sys/block/sd[a-f]/queue/iostats"