[Q] Edit line in file from terminal? - Android Q&A, Help & Troubleshooting

Hi, I don't really know where to put this topic but anyways my problem is that i need to edit a line in a file.
So i think of something like this
su
Cd /data/data/foldernameofapp/
Edit "file.dat"
Edit line 4 "text here 2"
i want it to edit like this "text here 3"
Change only the number. or replace the hole line with a new line where i only changed the number. btw the best is if the script can change a line and not find text and change. Because the number in the text i want to change can vary from different numbers.
Hope someone understands what i mean. Thanks in advance
P.S i can use root explorer and open the file with a text editor and change it, this works but takes forever
P.S.S i got root

This below will change "text here <whatever>" in oldfile.txt to "text here 3" in newfile.txt
Code:
$ busybox sed 's/text here .*/text here 3/' oldfile.txt > newfile.txt

kuisma said:
This below will change "text here <whatever>" in oldfile.txt to "text here 3" in newfile.txt
Code:
$ busybox sed 's/text here .*/text here 3/' oldfile.txt > newfile.txt
Click to expand...
Click to collapse
Okay but will it create a new file? Because I want it to save the old file.
Sent from my Galaxy Nexus using xda premium

julllleee said:
Okay but will it create a new file? Because I want it to save the old file.
Click to expand...
Click to collapse
I'm quite sure you can find out a way for the new file to live under the name of Sanders.

hmm i get this error. ser:bad option in substitution expression
Btw what do you mean with the last post? How do I save it? I can use your code and then maybe have another script after your thats remove the old file and then rename the new file to the old name?

sed 's/<zk_cp>0</zk_cp>.*/<zk_cp>6</zk_cp>/' zk.dat > zk2.dat

julllleee said:
sed 's/<zk_cp>0</zk_cp>.*/<zk_cp>6</zk_cp>/' zk.dat > zk2.dat
Click to expand...
Click to collapse
Ah, ok, you can't use / as delimiter if it occurs in the replacement strings as well. And yes, of course you can rename (mv) or copy (cp) the resulting files to get correct file names. Did you really have to ask that?
Code:
$ cp zk.dat zk.tmp
$ sed 's!<zk_cp>.*</zk_cp>!<zk_cp>6</zk_cp>!' zk.tmp > zk.dat

kuisma said:
Ah, ok, you can't use / as delimiter if it occurs in the replacement strings as well. And yes, of course you can rename (mv) or copy (cp) the resulting files to get correct file names. Did you really have to ask that?
Code:
$ cp zk.dat zk.tmp
$ sed 's!.*!6!' zk.tmp > zk.dat
Click to expand...
Click to collapse
Okay thanks I'll try the code
Sent from my Galaxy Nexus using xda premium

Wow works really good exactly as I want. I really appreciated it. You are the best!!
Sent from my Galaxy Nexus using xda premium

Related

[Q] 7zip for Android?

have anyone seen 7zip for Android?
AndroZip handels 7zip
Sent from my GT-I9000 using XDA App
MiMikri said:
AndroZip handels 7zip
Sent from my GT-I9000 using XDA App
Click to expand...
Click to collapse
Unless it is pw-protected.
AllGamer said:
have anyone seen 7zip for Android?
Click to expand...
Click to collapse
I've just compiled p7zip-9.20.1, it's the command line version of 7zip, if you still want it, you can download it from here:
http://dl.dbank.com/c0mtm6i3wa
(sorry, it's a file share site provided by Huawei company in Chinese language, outseas file share sites are blocked by "opening" China government)
Code:
$ uname -a
uname -a
Linux localhost 2.6.35.7-perf #1 PREEMPT Sat Dec 3 17:57:38 CST 2011 armv7l GNU/Linux
$ ls -l /system/bin/7z /data/local/bin/7za-9.20
ls -l /system/bin/7z /data/local/bin/7za-9.20
-rwxr-xr-x 1 2000 2000 1702540 Dec 26 03:37 /data/local/bin/7za-9.20
lrwxrwxrwx 1 0 0 24 Dec 26 03:03 /system/bin/7z -> /data/local/bin/7za-9.20
$ 7z
7z
7-Zip (A) 9.20 Copyright (c) 1999-2010 Igor Pavlov 2010-11-18
p7zip Version 9.20 (locale=C,Utf16=off,HugeFiles=on,1 CPU)
Usage: 7za <command> [<switches>...] <archive_name> [<file_names>...]
[<@listfiles...>]
<Commands>
a: Add files to archive
b: Benchmark
d: Delete files from archive
e: Extract files from archive (without using directory names)
l: List contents of archive
t: Test integrity of archive
u: Update files to archive
x: eXtract files with full paths
<Switches>
-ai[r[-|0]]{@listfile|!wildcard}: Include archives
-ax[r[-|0]]{@listfile|!wildcard}: eXclude archives
-bd: Disable percentage indicator
-i[r[-|0]]{@listfile|!wildcard}: Include filenames
-m{Parameters}: set compression Method
-o{Directory}: set Output directory
-p{Password}: set Password
-r[-|0]: Recurse subdirectories
-scs{UTF-8 | WIN | DOS}: set charset for list files
-sfx[{name}]: Create SFX archive
-si[{name}]: read data from stdin
-slt: show technical information for l (List) command
-so: write data to stdout
-ssc[-]: set sensitive case mode
-t{Type}: Set type of archive
-u[-][p#][q#][r#][x#][y#][z#][!newArchiveName]: Update options
-v{Size}[b|k|m|g]: Create volumes
-w[{path}]: assign Work directory. Empty path means a temporary directory
-x[r[-|0]]]{@listfile|!wildcard}: eXclude filenames
-y: assume Yes on all queries
Hi lovetide. What kind of compression did you use?
I can't find a way to open it :/
Guys I found another working port of p7zip for android.
I Tried to post a link but becouse i'm a 'noob' here i'm not allowed to.
So you can search for "port2android" at google and you will find it
ilbolza said:
Hi lovetide. What kind of compression did you use?
I can't find a way to open it :/
Click to expand...
Click to collapse
It's not an archive file, it's an executable file, you can execute it directly. It's static linked, so it should work on most Android phones.
lovetide said:
I've just compiled p7zip-9.20.1, it's the command line version of 7zip, if you still want it, you can download it from here:
http://dl.dbank.com/c0mtm6i3wa
(sorry, it's a file share site provided by Huawei company in Chinese language, outseas file share sites are blocked by "opening" China government)
Click to expand...
Click to collapse
Link does demand to pay for it. Can you upload attachment on the forum?
You have to click the link several times. It will work after some time.
But scroll down... Mirror is attached.
Here version 9.38.1 for arm-v7a, 7za is standalone, 7z needs 7z.so in /system/lib, 7zr a reduced version of 7za, Codecs must be in current dir for rar support (optional)
in the archive I've also added makefile.machine if you want to compile from source (you need to replace the one in the source directory, it needs to be edited for paths)
sherpya said:
Here version 9.38.1 for arm-v7a, 7za is standalone, 7z needs 7z.so in /system/lib, 7zr a reduced version of 7za, Codecs must be in current dir for rar support (optional)
in the archive I've also added makefile.machine if you want to compile from source (you need to replace the one in the source directory, it needs to be edited for paths)
Click to expand...
Click to collapse
Thank you very much for this indeed. XDA won't let it download no matter how many times I try, would it be possible for you to post it in a mirror somewhere ?
Edit : Never mind, finally got it. XDA glitch.
Edit 2 : Shoot, this will not run in Android 5 and newer systems... ( Error: only position independent executables (PIE) are supported. )
sorry but I didn't have an arm android 5.x to test it, I'm attaching pie build, I think it should work also on android < 5, but anyway there is still the old attachment in previous post
Hey...
I think the Zarchiver app from the play store would just work.
Hit thanks if I helped you!
ClawSpark said:
Hey...
I think the Zarchiver app from the play store would just work.
Click to expand...
Click to collapse
Does it support being called via command line, from eg a bash script?
To the rest: did the PIE build work fine?
p7zip 16.02 stand-alone attached.
help needed. anybody know how to set HugeFiles=on? compiling with -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE does not give expected result
- - -
edit: many thanks to superbeef150 @ XDA for solution!
aIecxs said:
p7zip 16.02 stand-alone attached.
help needed. anybody know how to set HugeFiles=on? compiling with -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE does not give expected result
Click to expand...
Click to collapse
Does this work on Android 6.0?
aIecxs said:
p7zip 16.02 stand-alone attached.
Click to expand...
Click to collapse
Thanks for sharing! I'm able to get this to run on several devices, but for some reason it errors out when running it in TWRP (which is coincidentally where I hope to run it):
Code:
~ # chmod 777 /data/local/tmp/p7zip
~ # /data/local/tmp/p7zip
/sbin/sh: /data/local/tmp/p7zip: not found
~ # sh /data/local/tmp/p7zip
/data/local/tmp/p7zip: line 1: syntax error: unexpected word (expecting ")")
Has anyone observed this different behavior between TWRP and the normal OS occur with 7zip or any other terminal/shell/CLI apps?
superbeef150 said:
Has anyone observed this different behavior between TWRP and the normal OS occur with 7zip or any other terminal/shell/CLI apps?
Click to expand...
Click to collapse
I got this figured out in case anyone stumbles across this in the future.
The default shell in TWRP (in my case) is at /sbin/sh . From what I've read, it sounds like this is the one that is supplied with BusyBox rather than the normal one. When I ran 7z using /system/bin/sh I had a lot better luck.
I'm now running into issues with larger ISO files. It seems like ones over 2GB are the problematic ones, I can't extract, test, or list contents on them, instead I always get an "E_FAIL" error message.
Googling that in the context of 7z seems to indicate a space issue, but testing and listing contents should make that irrelevant. For the sake of trying I attempted this with the ISOs on an exFAT usb flash drive as well as an NTFS usb hard drive with the same results.
I suspect that the HugeFiles=off setting that @aIecxs mentioned earlier may be related, but unfortunately the only information on the topic I could find were on one of his posts on p7zip's SourceForge forum where someone suggested a few different compile flags that didn't seem to make a difference for him or myself.
If anyone has any thoughts on this I'd really appreciate it! Thanks!
maybe compiling on 64-bit machine will support Hugefiles
aIecxs said:
maybe compiling on 64-bit machine will support Hugefiles
Click to expand...
Click to collapse
I'm doing that currently, but unfortunately HugeFiles is still showing up as off :/

[Q] Please help me change my android id

so i used all my offers for in game premium content and i would like to do them agin, i belive its possible if i change my id cause i did the same offers on my friends phone, am using rooted SE Live i have found settings.db in Data/data using root browser and opened the db with phone notepad, now can anyone help me out what should i edit to change my id and is there anything i need to do after it not to brick my phone, thx alot!
mladen190 said:
so i used all my offers for in game premium content and i would like to do them agin, i belive its possible if i change my id cause i did the same offers on my friends phone, am using rooted SE Live i have found settings.db in Data/data using root browser and opened the db with phone notepad, now can anyone help me out what should i edit to change my id and is there anything i need to do after it not to brick my phone, thx alot!
Click to expand...
Click to collapse
This is easy if you are rooted and have busybox:
It's easier to adb shell instead of manually typing this on a terminal emulator:
Code:
$ su
# cd /data/data/com.android.providers.settings/databases/
# sqlite3 settings.db
You will get a "sqlite>" prompt. enter the commands into the prompt:
Code:
insert into secure ("name", "value" ) values ("android_id","DEVICE_ID_GOES_HERE");
.exit
If you do not have a new ID to put in, I believe you can pick any 16 character hex number [A-F and 0-9].
Then after that, I would reboot just to be sure the change is reflected immediately.

[ROOT] LG Optimus L9 P760 P765 P768 P769

Follow thread http://forum.xda-developers.com/showthread.php?t=2173465
First of all , I'm not responsible for any damage..
Of course that's a rough explanation(i really need to hit the bed) but I hope you get the idea and someone will create more clearer and friendly instruction/guide/how-to/whatever.
When flashing L9 , LG App extracts files into C:\ProgramData\LGMOBILEAX\Phone ,
LGP769_AP[6].bin (contains /system partition which includes hdcp.sh) and that can be easly modified(image) and replaced during flashing process.
adb push su /data/local/tmp/
adb push busybox /data/local/tmp/
adb push Superuser.apk /data/local/tmp/
adb push rooting.sh /data/local/tmp/
adb shell chmod 777 /data/local/tmp/busybox
adb shell chmod 777 /data/local/tmp/rooting.sh
Follow thread http://forum.xda-developers.com/showthread.php?t=2173465
Downloading 10g kdz now. Will post back after I try to work this out. Thanks alot dude.
@lelus,
I am old dos buzz, so looking at the hexediting done by you in the BIN file, I can say that I am getting some hints.
You are suggesting to quietly replace the BIN file, in the middle of flashing KDZ file (when it is extracted to following folder), right?
C:\ProgramData\LGMOBILEAX\Phone\LGP769_AP[6].bin
The question is at which point the BIN file is to be changed? I still am confused with the sequence of BIN file replacement, scripts and files pushed via ADB. When these procedures are to be done? before flashing or after flashing?
I get hint that, you have modified BIN file to bypass the script file "hdcp.sh" which is used by LG Tool while flashing and instead of that, you are instructing to push+execute modified script "/data/local/tmp/rooting.sh". This new script is added in the beginning of BIN file, does that mean it will be executed everytime we reboot the phone? I may be wrong, just wanna clarify.
I dont have P769 device (good for me ), else I would have try that by now.
You can push the files and set permissions.
Flash your phone once to copy LGP769_AP[6].bin (it goes up to [10] and takes some time to extract the files, there should be enough time) from C:\ProgramData\LGMOBILEAX\Phone\ to some location.
Modify LGP769_AP[6].bin with a hex editor
Flash you phone once again,just like before you'll see lg flash tool decompressing files into C:\ProgramData\LGMOBILEAX\Phone\, when you see it done with LGP769_AP[6].bin copy/replace original with modded file, like before there should be enough time for it. Phone should be rooted after reboot.
hdcp.sh is setuid root and is executed at boot
Re: root p769 v10g and possibly other variants
Im very new to rooting. I've only rooted one phone(lg optimus p509). I now have my fancy new p769 and want some superuser action. I've been doing a lot of reading, and frankly, im worried about bricking or screwing up my new phone! When the more indepth description of your new found genius is released, could you please include details on exactly how to keep my phone safe and unbricked..THANKS!
Sent from my LG-P769 using xda premium
matts0807 said:
Im very new to rooting. I've only rooted one phone(lg optimus p509). I now have my fancy new p769 and want some superuser action. I've been doing a lot of reading, and frankly, im worried about bricking or screwing up my new phone! When the more indepth description of your new found genius is released, could you please include details on exactly how to keep my phone safe and unbricked..THANKS!
Sent from my LG-P769 using xda premium
Click to expand...
Click to collapse
As you say you are very new, I advice do not try this method at the moment. its very serious and you may brick your phone.
OK. My phone now rooted. But I only get root in adb shell only. Other root required app in phone don't popup Superuser dialog. My app cannot gain root access even I set "Automatic Response" to "Allow". Any Idea?
My phone firmware is p768f V10D, hdcp.sh is in LGP768_AP[5].bin. For other model I think your method should work if you can find proper file to edit (with hex edit).
Ha. Finally work. I replace su and Superuser from their website (After trial and error I don't know what the problem at first). I'm not sure if improper edit .bin file will brick your phone. So wait for some dev to confirm it. If you're not familiar with Hex editor I don't suggest you do this for now.
This may make me sound stupid, but could someone please post a clear set of directions to follow for this method. I think I understand it, but this is my only phone at the moment, and I don't want to screw it up because I swapped up a couple of steps.
For people who want to root LG L9 ICS Phone, please follow this guide http://forum.xda-developers.com/showthread.php?t=2173465
The method in this thread lack some steps to clean out rooting staff and script
For those who interest, below are the steps I did to root my phone from Lelus post info.
*** Please read it carefully and understand every step before you try. I cannot help you if you brick your phone. And please note that I'm not a android dev and these steps work for Lelus P769 10G and my P768f 10D. It should work in all variants but I'm not guarantee. ***
0. Find your KDZ at http://forum.xda-developers.com/showthread.php?t=2107971
1. Manually extract my kdz with LGExtract 0.2.1 from http://forum.xda-developers.com/showthread.php?t=1566532
2. Copy kdz (my file is V10D_00.kdz) and LGExtract.exe to C:\root\ , In command prompt just run
C:\root>LGExtract.exe -kdz V10D_00.kdz
3. You got V10D_00.cab
4. Extract cab with 7z or other zip program that can handle .cab (Google for it if you don't have it yet.) you got 2 files. LGP768.dll and V10D.wdb
5. Extract wdb with following command
C:\root>LGExtract.exe -wdb V10D.wdb LGP768.dll
*** don't forget my model is P768, you should change it to match the file you got ***
6. You'll found extracted files in BIN directory. After this step use your favorite Hex edit to search for hdcp.sh . I found it in LGP768_AP[5].bin. If you copy text from hex edit it look like following
# hdcp.sh
#
# [email protected], [email protected] , [email protected]
#
# HDCP sh file
#!/system/bin/sh
if ls /persist/mhl/key.bin ; then
echo "alreay exist" > /data/mhl.log
/system/xbin/hdcp-init 1 3 >> /data/mhl.log
echo "step 1 : hdcp on" >> /data/mhl.log
else
if ls /persist/en_hdcp.bin ; then
rm /persist/en_hdcp.bin
fi
echo "not exist" > /data/mhl.log
fi
7. In your hex editor, try to edit that file to following
#!/system/bin/sh
/data/local/tmp/rooting.sh
#.com , [email protected]
#
# HDCP sh file
#!/system/bin/sh
if ls /persist/mhl/key.bin ; then
echo "alreay exist" > /data/mhl.log
/system/xbin/hdcp-init 1 3 >> /data/mhl.log
echo "step 1 : hdcp on" >> /data/mhl.log
else
if ls /persist/en_hdcp.bin ; then
rm /persist/en_hdcp.bin
fi
echo "not exist" > /data/mhl.log
fi
*** for those who not familiar with Hex edit you must edit both left (HEX) and right side (TEXT) of editor because some characters is not on keyboard (ex. ENTER, just type 0a in left side editor to make ENTER key).
8. Trial and error until your copy text look like code above (you can copy your edited text from hex editor to text editor to examine it). Then save your file.
9. Next step is download all required file from Lelus link (or from my root.7z) and place them in C:\root
10. In command prompt run
cd C:\root
adb push su /data/local/tmp/
adb push busybox /data/local/tmp/
adb push Superuser.apk /data/local/tmp/
adb push rooting.sh /data/local/tmp/
adb shell chmod 777 /data/local/tmp/busybox
adb shell chmod 777 /data/local/tmp/rooting.sh
*** You can use adb.exe from http://forum.xda-developers.com/showthread.php?t=2085344 thread if you don't install android delveloper tools
11. All files should upload to your phone. After this step try to flash your normal unextracted kdz. You should open C:\ProgramData\LGMOBILEAX\Phone while flashing your rom. After kdz flash program show about 8% progress you should see that there are extract .bin files in that directory. Just quickly copy your edited .bin file (only the file that contain hdcp.sh script) and replace extracted file with it. *** you should wait for flash program to finish extract your file before replace it. ***
Read about how to flash your phone at http://forum.xda-developers.com/showthread.php?t=2085344
12. Done. You phone reboot with Superuser app install. If you have any problem like me that Superuser app don't popup to ask permission, please download latest version from http://androidsu.com/superuser/. I also upload updated files in root.7z below.
13. From Lelus' suggestion : After rooting I would probably suggest
adb shell rm /data/local/tmp/rooting.sh
adb shell touch /data/local/tmp/rooting.sh
adb shell chmod 755 /data/local/tmp/rooting.sh
Thanks Lelus for sharing this, :good:
Edit : Add updated Su, Superuser, LGExtract.exe, hex editor image and rooting.sh
Good one artit.
Do you think all LGP768_AP[5].bin (or other variants) are the same file (so we can uploaded a modified one and everyone can use it)?
Would this be a universal way of rooting all LG phone?
Thank You Lelus!
If this works everyone should click the "Thanks" button on Lelus' post.
---------- Post added at 09:35 AM ---------- Previous post was at 09:34 AM ----------
chicguy said:
Good one artit.
Do you think all LGP768_AP[5].bin (or other variants) are the same file (so we can uploaded a modified one and everyone can use it)?
Would this be a universal way of rooting all LG phone?
Click to expand...
Click to collapse
No. All bin files will be different since it holds the partitions and files that are loaded on the devices.
What I means is within the same variants, would it be the same kdz file downloaded? Then we can upload one bin file corresponding to each kdz file?
artit said:
1. Manually extract my kdz with LGExtract 0.2.1 from http://forum.xda-developers.com/showthread.php?t=1566532
2. Copy kdz (my file is V10D_00.kdz) and LGExtract.exe to C:\root\ , In command prompt just run
C:\root>LGExtract.exe -kdz V10D_00.kdz
3. You got V10D_00.cab
4. Extract cab with 7z or other zip program that can handle .cab (Google for it if you don't have it yet.) you got 2 files. LGP768.dll and V10D.wdb
5. Extract wdb with following command
C:\root>LGExtract.exe -wdb V10D.wdb LGP768.dll
*** don't forget my model is P768, you should change it to match the file you got ***
6. You'll found extracted files in BIN directory. After this step use your favorite Hex edit to search for hdcp.sh . I found it in LGP768_AP[5].bin. If you copy text from hex edit it look like following
Click to expand...
Click to collapse
Welldone! Artit! Thanks a lot.
For this same above process I have made a quick and small batch file of KDZ extraction tool and it keeps LGP768_AP
[*].bin files in single folder for further use.
By the way, when I looked for hdcp.sh in P760V10I, I found hdcp.sh in LGP760_AP[6].bin exactly as mentioned by Lelus. It seems the location of this text is different in BIN file and when extracting it goes to any piece of BINs, not always in 6th piece.
EDIT: Are you using Offline Flash method? Or online?
chicguy said:
What I means is within the same variants, would it be the same kdz file downloaded? Then we can upload one bin file corresponding to each kdz file?
Click to expand...
Click to collapse
I do not know.
I have modified .bin files for 11A and 10G on my home pc. I will upload them when I get home later if no one has already.
rooted
Thanks. Now i got P769bk us tmobile rooted.
Hash editor each hash key must match in same place. sd card removal helped.
Uploaded the V10g modded binary for P769. MD5 checksum included, but I forgot to change the directory in the file that checks it (but you can change it).
filedropper[dot]com/lgp769v10g-bin
gigasize[dot]com/get/t23b42m76yc
MD5: c2cbf3997a9ab7181c71c75d697db6f5
Where is the www[dot]zip file for the OFFLINE FOTA method of flashing (/showthread.php?t=2085344)?
EDIT: Please disregard this post. This was a result of a corrupted download. shttps.zip will include the www directory.
V11a rooted as well!

[tutorial]Add build.prop lines from cwm

I have seen many questions about build.prop editing but very less of them have been convincing to be solved and modders don't need to tell people to add lines from next time​
First how to make a script sh file which contains your prop lines
Click to expand...
Click to collapse
Open npp and type:
#!/sbin/sh[This is the first line to call busybox]
busybox echo "" >> /system/build.prop[Call busybox for prop file]
busybox echo "Title of your added lines" >> /system/build.prop(not recommended but works absolutely)[This is the description line which is written inside build.prop for understanding of your apk's value nature..]
busybox echo "ro.config.ringtone=opal.ogg" >> /system/build.prop....(And just the same way add lines)[This line put your default ringtone to opal.ogg]
Provide a line break
busybox echo "" >> /system/build.prop[Call this line again for busybox to finish prop file]
save file with script.sh extension.....save it at the main folder which contains meta-inf folder too...
Add these lines to updater-script after
Click to expand...
Click to collapse
ui_print("Adding lines to build.prop");
package_extract_file("script.sh", "/tmp/script.sh");
set_perm(0, 0, 0777, "/tmp/script.sh");
run_program("/tmp/script.sh");
For modifying the script ...like deleting prop lines....its quite hard to manage through it..end up in bootloops...will see to work it out...if any of you have got the deleting prop lines successful then post here
Try this one
Code:
{ sed -i "/^$1=/{ h; s/^$1=\(.*\)/# $1 was \"\1\"\n$1=$2/ }; \${ x; s/$1//; x; t e; s/$/\n$1=$2/; : e }" "$TMP"; }
this will search your build.prop for a line and replace it with something that you want it to be... then it will echo all of that to a temporary file of your choosing for reference. it will also comment out what the old prop was
RErick said:
Try this one
Code:
{ sed -i "/^$1=/{ h; s/^$1=\(.*\)/# $1 was \"\1\"\n$1=$2/ }; \${ x; s/$1//; x; t e; s/$/\n$1=$2/; : e }" "$TMP"; }
this will search your build.prop for a line and replace it with something that you want it to be... then it will echo all of that to a temporary file of your choosing for reference. it will also comment out what the old prop was
Click to expand...
Click to collapse
Great..i will work through it
epicsilence said:
I have seen many questions about build.prop editing but very less of them have been convincing to be solved and modders don't need to tell people to add lines from next time​
Open npp and type:
#!/sbin/sh[This is the first line to call busybox]
busybox echo "" >> /system/build.prop[Call busybox for prop file]
busybox echo "Title of your added lines" >> /system/build.prop(not recommended but works absolutely)[This is the description line which is written inside build.prop for understanding of your apk's value nature..]
busybox echo "ro.config.ringtone=opal.ogg" >> /system/build.prop....(And just the same way add lines)[This line put your default ringtone to opal.ogg]
Provide a line break
busybox echo "" >> /system/build.prop[Call this line again for busybox to finish prop file]
save file with script.sh extension.....save it at the main folder which contains meta-inf folder too...
ui_print("Adding lines to build.prop");
package_extract_file("script.sh", "/tmp/script.sh");
set_perm(0, 0, 0777, "/tmp/script.sh");
run_program("/tmp/script.sh");
Click to expand...
Click to collapse
I cant quite understand this. Could you please make a simple way on how to do this. thanks :fingers-crossed:
Najmi Mansor said:
I cant quite understand this. Could you please make a simple way on how to do this. thanks :fingers-crossed:
Click to expand...
Click to collapse
1. Don't quote full op
2.Nope there is no other simple method, you may learn from now
Najmi Mansor said:
I cant quite understand this. Could you please make a simple way on how to do this. thanks :fingers-crossed:
Click to expand...
Click to collapse
Friend, npp means notepad ++ ..you can get it from sourceforge.net ...and for later instructions type and understand meaning written in brackets
And yes...you need to read more threads around xda so you can understand more threads easily..
Enjoy reading
RErick said:
Try this one
Code:
{ sed -i "/^$1=/{ h; s/^$1=\(.*\)/# $1 was \"\1\"\n$1=$2/ }; \${ x; s/$1//; x; t e; s/$/\n$1=$2/; : e }" "$TMP"; }
this will search your build.prop for a line and replace it with something that you want it to be... then it will echo all of that to a temporary file of your choosing for reference. it will also comment out what the old prop was
Click to expand...
Click to collapse
Can you explain this a bit further in terms of usage? What part of this code is the line to be replaced and the line to be supplanted? I assume 1 & 2 are the lines, but I still don't quite understand... Maybe you could give an example? Thank you.
epicsilence said:
Friend, npp means notepad ++ ..you can get it from sourceforge.net ...and for later instructions type and understand meaning written in brackets
And yes...you need to read more threads around xda so you can understand more threads easily..
Enjoy reading
Click to expand...
Click to collapse
Thanks for replying
Heatshiver said:
Can you explain this a bit further in terms of usage?
Click to expand...
Click to collapse
Hello, learn more about sed here...my friend once implemented it on galaxy s2 for verification....but same script did not applied for xperia series...so i think its more important to get to know deep about its usage......
SED-Complete Document(Unofficial)
Always share knowledge, sometimes we might get more than we know
anybody has sample zip for this including updater script commands and the file script.sh, thanks anyone can help
---------- Post added at 04:14 AM ---------- Previous post was at 03:30 AM ----------
TheDriller said:
Try this one
Code:
{ sed -i "/^$1=/{ h; s/^$1=\(.*\)/# $1 was \"\1\"\n$1=$2/ }; \${ x; s/$1//; x; t e; s/$/\n$1=$2/; : e }" "$TMP"; }
this will search your build.prop for a line and replace it with something that you want it to be... then it will echo all of that to a temporary file of your choosing for reference. it will also comment out what the old prop was
Click to expand...
Click to collapse
can u give an example of a line that ur trying to replace in buildprop? what if this line ro.config.dha_empty_max=36 you change the value to 40 . . pls? thanks

[Q] how to use a script to replace text in a file?

i want to use a script to change text in build.prop
the script has to look for:
ro.something: (text to change)
and change the (text to change)
how?
washwash said:
i want to use a script to change text in build.prop
the script has to look for:
ro.something: (text to change)
and change the (text to change)
how?
Click to expand...
Click to collapse
One way would be to make use of the sed command in a script, coupled with other commands such as grep you can search for the property you want and replace the values of it once you find the property your looking for. I would recommend taking a look at the sed documentation, as well as this tool which does something similar to what you want to do.

Categories

Resources