Thanks for the quick reply. I am facing a small issue. Its replacing other numbers too. I want to specifically replace only percentages from 90 to 100.
Aia,
Standard sed uses BREs; not EREs. Basic regular expressions do not include alternation (i.e., BRE|BRE). Furthermore, we don't know what separates a percentage to be quoted from its surroundings. With the following input:
a standard sed (with your suggested command) produces the output:
(which I do not believe is what is wanted) and your perl script produces:
(which I assume is closer to what is wanted).
I believe that what was requested was:
but, without confirmation that that really is what is wanted from ctrid, I'm not going to try to produce a different sed or awk script that does what I might think would be a more reasonable interpretation.
ctrid,
Please give us a clear specification of what, if any, characters or strings appearing adjacent to a percentage should keep it from being quoted. (If a period or comma is to be interpreted as part of a percentage, are these characters locale specific?) Should something like 91.50% (in the C Locale) be quoted (since it is in the range 90% to 100%, inclusive)?
This User Gave Thanks to Don Cragun For This Post:
[...]
but, without confirmation that that really is what is wanted from ctrid, I'm not going to try to produce a different sed or awk script that does what I might think would be a more reasonable interpretation.
[...]
Don,
A times overthinking it is paralyzing, as it just happened to you.
Appreciate you.
Very good catch. Even I didn't anticipate the decimals.
As you said there could be decimals.
But
or
or
would not be in my input text file. All percentages are delimited by space and no periods or any other characters appear anywhere.
Hence only danger I see is of decimals. Don, Thanks once again for pointing out this.
Aia, your one liner is cool, it works for now. As Don said I have an issue only if my input file changes with decimals. How do I modify this perl statement to take care of that?
i have little challenge, help me out.i have a file where i have a value declared and and i have to replace the value when called. for example i have the value for abc and ccc. now i have to substitute the value of
value abc and ccc in the place of them.
Input File:
go to &abc=ddd;
if... (16 Replies)
Hi All
I am having pipe seperated inputs like
Adam|PeteR|Josh|PEter
Nick|Rave|Simon|Paul
Steve|smith|PETER|Josh
Andrew|Daniel|StAlin|peter
Rick|PETer|ADam|RAVE
i want to repleace all the occurrence of peter (in any case pattern PeteR,PEter,PETER,peter,PETer) with Peter so that output... (5 Replies)
Hi,
I have a file which contains the below data. I want to search for a pattern server="http://bushby.mis.amat.com:12440" and remove it from the file.
Please let me know how can i do this.
<Object name="reverse-proxy-/endeavour/">
ObjectType fn="http-client-config" timeout="1800"... (6 Replies)
Hi,
I have a file which contains the below data. I want to change pattern to correct format.
# tail -1 test.log | awk '{print $8}'
10/09/23
#
I want the format to be 23/09/10 (5 Replies)
Hi all,
I been searching the forum for a few hours now and can't find exactly what I need to replace text between two patterns. Below is what I want to accomplish
/* Any text between these to sympols */
changed to....
/* This will be the new text to change */
..and I'm... (3 Replies)
Hi all
I need to replace all characters in a file except for the matching pattern
eg.
I need to replace all character with '*' except for the pattern "abc"
Input
"sdfhgsdf abc ##%$#abcsdfh sdfjkfff"
Output
"******abc******abc*************"
Request for single liner solution (1 Reply)
Hi guys,
i have a pattern that i am searching in a file and i want to extract some of this pattern
...
module TS1N65ULPA96X32M4 (
....
i want to extract only TS1N65ULPA96X32M4 part and i do the following
sed 's/module \(x*\).*/\1/' name_of_file
but this is not quite right.
could... (6 Replies)
My String variable is holding value as - abc"def
I want to replce " with \"
I tried with awk :
echo $var | awk '{gsub(/"/,"\"");print}'
and I am getting an error, `)' is not expected. (1 Reply)