Using sed to change lines and add them if they don't exist..
I've googled the hell out of this, and in my quest to advance my knowledge and expertise in modifying phones to make them more awesome, I ended up here.
I've found answers about patterns and whatnot that seem really complex for what I am trying to do, and basically it is this:
if the line says
I want to change it to
- if I understand right then that would be easy -
(the file I am modifying)
But what would be the easiest way to add that line IF there was no line that contained "ro.ril.gprsclass="?
I know this may be a dumb question, but I am looking for the SIMPLEST way of doing this(there will be many lines modified like this, and I want to keep it simple to avoid possible errors)?
I am only trying to modify/add the lines that start with RO(read-only), I can create another file that will supercede any files that don't start with that..
In case it helps, what I have so far is:
The last line will replace a line I KNOW is there, but I need this answer to make sure that I don't create multiple entries of the same code(and the first entry takes precedence anyways)
If anything here is unclear let me know, but for me I am clearly going from developing for a phone to coding- and all the instructions I have found thus far are complex or just plain confusing..
---------- Post updated at 09:01 AM ---------- Previous update was at 12:22 AM ----------
Someone in the phone forums said I could use grep + sed to get it done, they didn't give me a solid example, but I'm guessing it would look something like this?
I'm unsure about the formatting, but if the above worked and there WAS a line that said "ro.ril.gprsclass=8" it would change it to 12, or if there was no line it would add it to the end of the original file.. am I correct?
I'd appreciate any feedback, it seems much easier to find complex ways of doing these things that may work, much harder to find the simplest way that WILL work..
Thanks in advance!
SBD
Last edited by Silentbtdeadly; 05-11-2012 at 11:33 AM..
Reason: Code tags were being used, but added some extra code tags
When trying to change the password with the command "passwd" it returns that the user does not exist.
passwd <USER>
passwd: changing password for <USER>
passwd: <USER> does not exist
This is a Solaris 2.5.1 system. (7 Replies)
Hello,
I have a file that has data like this:
one two three four
five
six seven
eight nine ten
Is there a quick way using sed of nawk to put each word on it's own line?
Thanks. (2 Replies)
Hi,
How can i use insert and change command in ksh shell.
I am using :
sed -e '1i\TEXTTOBEINSERTED\' FILENAME
But there is no effect...
Also
sed -e 'c\thisischange\' Filename
Please Explain how to proceed?? (2 Replies)
I want to get an output from the input as below:
Input:
ASDDS14 RXOTX-39-8 AB0991C TRY1900
AEDFS12 RXOTX-39-9 TK0991C TRY800
HSVDS11 RXOTX-389-10 LG0991C TRY1900
BSDDS09 RXOTX-394-0 AA0066A TRY800
OUTPUT:
ASDDS14 RXOTS-39-8-0 AB0991C TRY1900... (2 Replies)
Hi,
I want to add a character "#" in this few lines with sed command
Initial:
### CACCIA: DEBUT ###
if $(grep -wqi "$2" /etc/passwd); then
chuser -R files registry=files $2
fi
### CACCIA: FIN ###
Result with sed command:
### CACCIA: DEBUT ###
#if $(grep -wqi "$2"... (4 Replies)
Hi
I have to list of words file1 and file2, I want to compare both lists and remove from file2 all the words that don't exist in file1.
How can I do this?
Many thanks (4 Replies)
Hi,
A file is transferred from a Windows server(say username : user1) to Unix server via ftp.
In unix, the permission of the file for a user, say user2 will be "-rw-r-----". Since the user1 is the owner of the file, user2 is not able to change the file permission using chmod.
Is there... (5 Replies)
Hi,
I am writing a shell script where I want that # should be added in all those lines as the first character where the pattern matches.
file has lot of functions defined
a.sh
#!/bin/bash
fn a {
beautiful evening
sunny day
}
fn b {
}
fn c {
hello world .its a beautiful day
... (12 Replies)
Hello all,
I have surely an easy question - but at the moment I do not see the solution.
All what I want is to add the string "/9201" within a file when a line starts with ":47A:".
This is how a file look like:
Information Tool
:12:Delimiter
:3:Space
:47A:0329
:3:Space After the... (2 Replies)