I am trying to find an Android shell command that is able to read a file but that has the power to skip, for example 512 bytes every 1024 bytes.

Does such a command exist and is available for Android devices?

I have looked at dd documentation but couldn't figure out if it is possible to use dd for that purpose. You can make dd skip bytes at the beginning of the file, you can make it read X bytes from a file, but I do not see how to get the feature that I described.


For my purpose the command/script should output to stdout, and the processing will read the output like a stream, so it will not be something like "cat a file, do processing, cat a file". It is like "while true; do cat a file; done | processing".

The list of available commands is here: http://www.busybox.net/downloads/BusyBox.html

1 Answer 1


You should try to use this bash script I wrote for you (require busybox on your Android):

put the script in a file called script.bash (change with your own path) :

# sputnick 20120928 http://android.stackexchange.com/posts/30069

bytes=$(wc -c < $binfile)
c=0 count=0

while ((count < bytes - (1024+512) )); do
    dd 2>/dev/null if=$binfile bs=512 count=2 skip=$c
    printf '\n\n'
    ((count += 1024+512 ))

Now, in a terminal on your computer (this is for linux, adapt it if you use Windows)

adb push script.bash /mnt/sdcard/script.bash
adb shell
chmod +x /mnt/sdcard/script.bash


This is what the script does in-fine :

dd 2>/dev/null if=/tmp/bin bs=512 count=2 skip=0
dd 2>/dev/null if=/tmp/bin bs=512 count=2 skip=3
dd 2>/dev/null if=/tmp/bin bs=512 count=2 skip=6
dd 2>/dev/null if=/tmp/bin bs=512 count=2 skip=9
  • That certainly should work but I see two details that could be improved for my purpose. First I want it to output to stdout and not to several files. I think you can fix that just by removing the of option. The other thing is, I do not know if calling dd several times brings an overhead of opening/closing the file several times making the process less efficient than it should be. Commented Sep 29, 2012 at 12:08
  • 1
    The script was edited to fit your needs. If you know a better way than calling dd several times, tell me how ;) Commented Sep 29, 2012 at 14:44

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .