My Input file contains a 1000�s of lines in which I have to replace a
a string to the other. Here the problem is, I have the lines in my Input as below.
Cable Yes && !Pay TV && !ADS
\noUE \Label="Cable Yes && !Pay TV && !ADS"
I want to replace exactly the string Cable Yes && !Pay TV && !ADS with Cable Yes && !Pay TV && !ADS && !MDS .
I do not want to replace when my string is preceding with some other words or ending with some other words.
More clearly I want to replace if it is like line 1 of my Input. I do not want to replace if it is like line 2 of my Input.
I have tried the below codes, but not able to get the results
sed 's/"Cable Yes && !Pay TV && !ADS"/"Cable Yes && !Pay TV && !ADS && !MDS"/' file
nawk '{sub(/\<Cable Yes && !Pay TV && !ADS \>/,"Cable Yes && !Pay TV && !ADS && !MDS")}1' file
sed "s/\< Cable Yes && !Pay TV && !ADS \>/Cable Yes && !Pay TV && !ADS && !MDS /" file
Thanks for your time. I have tried all the codes provided by you all. I am getting the same error message
Pay: Event not found
Ravinder, I have used the exact code given by you. But still the same error.
Also as per Scrutinizer comments, have used single quotes instead of double quotes. Still the same error.
I am working in Ksh shell. I do not have any idea about bash shell
Are you sure that's a ksh error message? It strongly reminds me of an unsuccessful bash history search...
The proposals in post#3 (hopefully) don't interfere with history expansion...
Do you see any inconsistency here between your claim that you are running ksh and the output above that clearly shows that you are running csh as your shell?
To change from running csh to actually run ksh , issue the command:
exec ksh
then, try one of the commands that was suggested above in this thread that was failing due to csh command history substitutions.
Yes Don. I did not understand why it showed csh in there while i am working in ksh shell.
Anyways, i will try as you suggested and will let you know the results.
Thanks & Regards,
am24
---------- Post updated at 01:57 AM ---------- Previous update was at 01:50 AM ----------
Hi Don,
Just need clarification. when i give the command exec ksh , the prompt chnaged to $ . where as earlier it is -> .
So the shell till now i worked is csh , is it ? Now with the command exec ksh i have moved to ksh shell. Am i correct ?
Regards,
am24
---------- Post updated at 02:08 AM ---------- Previous update was at 01:57 AM ----------
Hi Don,
I have given the command exec ksh . Then i tried all of the codes suggested by each one of you. I did not get any error like earlier but there was no required modifications done on my Input(Output is same as the Input).
could you please suggest me how can i proceed further on this ?
Again: difficult to believe. I'd sooner believe that all of the proposals have been tested before being posted here. Please give some evidence of your assertion by posting those commands running and their output.