Hi,
I have to grep value from one file, if that value is already present with "#" symbol. I have to remove that symbol in that file.
Ex:
file1.txt contains the following string
#value=15
I have to search for "Value". If I found the string with hash symbol, nee to remove the # in the file1.txt.
Please help on this.
Thanks,
Chelladurai.
perl -i.bck -pe's/#value/value/' file1.txt
pamu
3
cat file1.txt | sed 's/#//g' > temp_file
mv temp_file file1.txt
Hi,
Thanks for your reply. But i need to apply this in my shell scrpt.
Because, I want to validat the string in the file then replace it. Every loop contains different string values.
Like
perl -i.bck -pe's/#$tempvar/$tmpvar/' file1.txt
Could you please assist on this.... ????
# awk '/value/{if($0~/^#/)sub("^#","")}1' file
Use:
perl -i.bck -pe's/#$ENV{tempvar}/$ENV{tempvar}/' file1.txt
The variable tempvar must be exported.
Thanks for the reply. Its working fine....