shell command to create files

3.2k Views Asked by At

I want to create files with different sizes on an Android device. The one approach I have already tried was to create dummy files using fsutil and push it to devices.

Is there any way to achieve similar result with a command inside adb shell?

1

There are 1 best solutions below

1
alijandro On

Yes, you can do it using dd command. I am not pretty sure it's available in your device. It works fine in my device, you can give a try.

In your host which connects with your Android device, with adb debug turn on, using the following command to create dummy file.

adb shell 'dd if=/dev/zero of=/data/local/tmp/test.img bs=4k count=800'
# check the result
adb shell ls -l /data/local/tmp/test.img
-rw------- shell    shell     3276800 2017-06-21 17:33 test.img

The command above will get data from /dev/zero and output to /data/local/tmp/test.img (a public writable directory for Android device), adjust bs and count value in your situation.