Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to copy and edit files in Android shell?

The Android shell does not have the cp command. Android shell also has no sed or grep or vi. I have no adb daemon available. There is mv command but it rejects to work if source is on a read-only device.

  1. What to do if I have to copy some directories from read-only device recursively?
  2. How to change a line in a text file (e.g. "PATH=/cache" to be "PATH=/mnt/asec") ?
like image 212
psihodelia Avatar asked Jan 17 '11 14:01

psihodelia


People also ask

How do I copy and paste a file in shell script?

Click the file you want to copy to select it, or drag your mouse across multiple files to select them all. Press Ctrl + C to copy the files. Go to the folder into which you want to copy the files. Press Ctrl + V to paste in the files.

How do I copy files in bash shell?

Copy a File ( cp ) You can also copy a specific file to a new directory using the command cp followed by the name of the file you want to copy and the name of the directory to where you want to copy the file (e.g. cp filename directory-name ). For example, you can copy grades. txt from the home directory to documents .

How do you copy in shell?

If you highlight text in the terminal window with your mouse and hit Ctrl+Shift+C you'll copy that text into a clipboard buffer. You can use Ctrl+Shift+V to paste the copied text into the same terminal window, or into another terminal window.


2 Answers

To copy dirs, it seems you can use adb pull <remote> <local> if you want to copy file/dir from device, and adb push <local> <remote> to copy file/dir to device. Alternatively, just to copy a file, you can use a simple trick: cat source_file > dest_file. Note that this does not work for user-inaccessible paths.

To edit files, I have not found a simple solution, just some possible workarounds. Try this, it seems you can (after the setup) use it to edit files like busybox vi <filename>. Nano seems to be possible to use too.

like image 124
gnclmorais Avatar answered Sep 17 '22 17:09

gnclmorais


You can do it without root permissions:

cat srcfile > /mnt/sdcard/dstfile 
like image 40
Viriatvs Avatar answered Sep 20 '22 17:09

Viriatvs