Hello Experts,
I have a file "tt.txt" which is like:
#a1=a2
b1=b2
#c1=c2
I need to remove the pound (#) sign from a particular line. In this case let us assume it's 3rd line : "#c1=c2"
I can do it through:
sed "s/#c1=c2/c1=c2/" tt.txt
but it is possible that I may not know the value "c2" due to which I would not be able to use the above command.
Please point me in the right direction.
Thank You.
Regards,
HKansal
At least you have to know on what line or how to recognize the particular line (pattern?).
Regards
Hello,
Yes Franklin, as rightly said by you, that I can identify. The "c1" part is the only thing that I would know and it is unique, so locating the line is not a problem.
I want to make my substitution independent of the "c2" part.
Thank You.
Regards,
HKansal
awk '
/^#c1/{sub(/^#/,"")} # use when uncomment
/^c1/{sub(/^c1/,"#c1")}#use when want to comment
1' file
Hello,
Hey Ghostdog, that worked as good as you were sure about it. Thanks.
Also, for letting me know something more about "awk".
Any way to do it through sed, just for my information and learning!
I'll put up the complete script soon as I've been asking a lot of small questions, all to get through a composite script.
Thank You.
Regards,
HKansal
sed 's/^#c1/c1/' file # to uncomment
sed 's/^c1/#c1/' file # to comment
Hello,
I am posting the final script created under the initial thread :here:
Thank You
Regards,
HKansal