I try to uncomment specific lines from a file with patterns in oracle linux 8.6 using bash. There are leading white spaces on certain lines where the comments are not removed. I tried to uncomment the commented lines with sed and grep for matching the patterns. I need to exactly match two numbers from the output. There is one word per column(total 2 columns) in the file each with numbers.
Example: column1:pd19_ORA column2:svg38.
I need to uncomment lines inplace with exact match of 19 and 38 without 190,1900 or 019 etc.. excluding lines such as,
column1:pd**19**_ORA column2:svg**37** #pd19_ORA svg37
column1:pd**199**_ORA#pd199_ORA column2:svg**388**svg388
Code:
sed -n '/\<19\>/,+1p' cmfile|grep '38'|sed -i '/38/s/^#//g' cmfile
Contents of file:
#pd19_ORA svg38
#pd19_ORA sil38
#pd29_ORA sil37
First line is still commented after using sed with inplace but comment of second line is removed.
Output:
#pd19_ORA svg38
pd19_ORA sil38
#pd29_ORA sil37
How to remove the first line comment which has leading white spaces without removing the leading space?
Expected output:
pd19_ORA svg38
pd19_ORA sil38
#pd29_ORA sil37