Hi Everyone, i am new to scripting and stuck in something.
Query is : I have a properties file eg. data.properties.
This data.properties have some values
example :
key1=value1
key2=value2
#key3=value3
as key3 is commented by #.
so i want to write a script , that will remove # from properties file and if i want to add # infront of any value in properties file.
My script should be able to remove # or add # from a particular string.
Welcome to forums, please use code tags as per forum rules for commands/codes/Inputs you are showing into your posts. Following may help you in your requirement.
To remove leading # from the Input_file:
awk '{gsub(/^#/,X,$0);print}' Input_file
To add # into starting of a string.
awk '{gsub(/^key3/,"#"&,$0);print}' Input_file
I haven't tested both, please do let me know if this helps you.