start searching a word from the particular record on the result of first occurence change the value
Hi,
I need a script to start searching a word from the particular record on the result of first occurence i need to change the value in that record.
I have a input file like this
I would like to search a word "ContactAddress"(its unique value in a file) from here onwards i want to search a word "Restarts"(multiple occurences in a file) on the first occurence of result(<add key="Restarts" value="1000" /> ) in that i want to change the value 1000 to 500).
Thank you so much its working.
Could you please explain the command for my understanding
Is it possible to replace from its original file without redirecting to temporary file and again moving to original file.
I want to execute this as a command and not through the script
This expression is specifying a range of addresses to work upon and will select all blocks of lines containg "ContactAddress" in first line and "Restarts" in the last line. Since you mentioned that "ContactAddress" occurs only once in the file, only 1 such block is possible to be addressed by this expression.
In that selected block, in the last line (having the word "Restarts" which is the first occurrence of that word after "ContactAddress"), substitute a string of 1 or more digits with 500.
Check if your sed version supports in-place editing with the -i option.
Hi all,
I am trying to delete last occurrence of word using sed command.
for example.
I have input like this
on a.id1 = b.id1 and
on a.id2 = b.id2 and
on a.id3 = b.id3 and
and I am expecting output like this
on a.id1 = b.id1 and
on a.id2 = b.id2 and
on a.id3 = b.id3
I just need to... (11 Replies)
Hi Guys.
I guess I have a very basic query but stuck with it :(
I have a file in which I want to extract particular content. The content is between standard format like :
Verify stats
A=0
B=12
C=34
TEST Failed
Now I want to extract data between "Verify stats" & "TEST Failed" but do... (6 Replies)
I'm not getting the syntax correct to change a line only on the first occurrence:
I've tried to change only the first match and I've tried to change the from the second match forward
sed 's/<B>PT#/<tr><td class=\"pt1\" width=\"40%\"><B>pt#/1' $file > tmpfile.html
sed ... (0 Replies)
I have an array as follows:
Space: ABC
Name: def
Age: 22
Type: new
Name: fgh
Age: 34
Type: old
Space: XYZ
Name: pqr
Age: 44
Type: new
:
:
How can I separate the array with elements starting from Space:ABC until Space: XYZ & put them in a different array & so on... (4 Replies)
In a file I have to count a particular word. like i need apache how many times.
I tried this
$ tr "\011" "\012\012"<foo1 | tr -cd "" |sort\uniq -c
but I got result like this
32 apache
18 dns
12 doctor
Please sugest me (4 Replies)
Greetings,
I need to search and count all the occurences of a word in all the files in a directory.
Any suggestions greatly appreciated.
Thanks (1 Reply)
i have a file called file1
cat file1
i am namish
namish lives in India
India and namish both are good.
I want to delete all the occurences of namish in one shot,if i do it with sed i guess all the lines will be deleted containing the pattern.Suggest me any idea without AWK.
Thanks... (6 Replies)
I want to count the number of occurence of perticular word from one text file.
Please tell me "less" command is work in ksh or not. If it is not working then instead of that which command will work. :confused: (40 Replies)