Hi all,
I want to grep for "PATTERN" and only if "PATTERN" is in a line, this line shall be used as replacement input e.g. for SED.
I don't get it running in one line.
NOT RUNNING - just first idea... I don't know how to redirect grep output to be used by sed in file Input example:
Quote:
This is text
Nothing changes unless PATTERN is found and th replace string.
Now its changed! Because of PATTERN is found... random stuff 1234... to be changed
blah PATTERN 987654321 blub to be changed
nothing to be done - even if to be changed is here
Expected output example:
Quote:
This is text
Nothing changes unless PATTERN is found and th replace string.
Now its changed! Because of PATTERN is found... random stuff 1234... , YEHA! to be changed
blah PATTERN 987654321 blub , YEHA! to be changed
nothing to be done - even if to be changed is here
Sometimes you just can wonder why you didn't find it :-)
I now remember that it was possible to add a pattern in front of sed substitution.
I don't want to substitute again, if i was obviously done in steps before. So it should be like
1.) Find PATTERN
2.) Only if element is "to be changed" but NOT ", YEHA! to be changed"
2.1.) than substitute "to be chaned" to ", YEHA! to bechanged"
2.2.) else (do nothing)
Thanks a lot!
final outcome: ---------- Post updated at 03:15 PM ---------- Previous update was at 02:58 PM ----------
can I add a rule checking if substitution was done?
Example:
Input:
blah PATTERN 987654321 blub to be changed
Output after first run or otherwise manipulated: FINE
blah PATTERN 987654321 blub , YEHA! to be changed
Now if I rerun or if this was changed from other sources: SHOULD NOT BE SUBSTITUTED
blah PATTERN 987654321 blub , YEHA! , YEHA! to be changed
Note:
", YEHA! " can be between PATTERN and "to be changed" and rule should substitute if it's not directly in front of "to be changed"
Quote:
IN:
PATTERN 12345... , YEHA ...678 to be changed
PATTERN 12345... , YEHA ...678 , YEHA to be changed
OUT:
PATTERN 12345... , YEHA ...678 , YEHA to be changed
PATTERN 12345... , YEHA ...678 , YEHA to be changed
I have a file comp.pkglist which mention package version and release . In 'version change' and 'release change' line there are two versions 'old' and 'new' Version Change: --> Release Change: -->
cat comp.pkglist
Package list: nss-util-devel-3.28.4-1.el6_9.x86_64
Version Change: 3.28.4 -->... (1 Reply)
Sorry for the long/weird title but I'm stuck on a problem I have. I have this XML file:
</member>
<member>
<name>TransactionID</name>
<value><string>123456789123456</string></value>
</member>
<member>
<name>Number</name>
... (9 Replies)
I have a file example.txt as follows :SomeTextGoesHere
$$TODAY_DT=20140818
$$TODAY_DT=20140818
$$TODAY_DT=20140818I need to automatically update the date (20140818) in the above file, by getting the new date as argument, using a shell script.
(It would even be better if I could pass... (5 Replies)
here is what i want to achieve... consider a file contains below contents. the file size is large about 60mb
cat dump.sql
INSERT INTO `table1` (`id`, `action`, `date`, `descrip`, `lastModified`) VALUES (1,'Change','2011-05-05 00:00:00','Account Updated','2012-02-10... (10 Replies)
QUESTION1:
How do you grep only an exact string. I am using Solaris10 and do not have any GNU products installed.
Contents of car.txt
CAR1_KEY0
CAR1_KEY1
CAR2_KEY0
CAR2_KEY1
CAR1_KEY10
CURRENT COMMAND LINE: WHERE VARIABLE CAR_NUMBER=1 AND KEY_NUMBER=1
grep... (1 Reply)
Can someone tell me how I can do this?
e.g:
a=$(echo -e wert trewt ertert ertert ertert erttert
erterte
rterter
tertertert
ert)
How do i replace the STRING with $a?
I try this:
sed -i 's/STRING/'"$a"'/g' filename.ext
but this don' t work (2 Replies)
Can someone tell me how I can do this?
e.g:
Say file1.txt contains:
today is monday
the 22 of
NOVEMBER
2010
and file2.txt contains:
the
11th
month
of
How do i replace the word NOVEMBER with (5 Replies)
Hi all,
I know this question has probably been answered before, but I am struggling with this problem, even after googling a million pages.
In a file named rdmt.conf
I need a single character replaced, the number in the line below
CUR_OC4J_ID=1
It will always appear after... (3 Replies)
Hi,
I have a log file that I need to monitor as it's being written to, and I want to exclude certain strings from the output. At the moment I'm using ...
tail -f LogFileName_`date +%d`.log | egrep -v "First String To Exclude | 2nd string | 3rd string" ...which works OK - but now I need to... (1 Reply)