Hi,
I have the following file,
ABC.txt:
ABC=123
DEF=234
FGH=345
Based on my validation and conditional processing it is observed that i need to comment or append # before DEF=234
so the same file ABC.txt should look as follows
ABC=123
#DEF=234
FGH=345
Sorry if its a repost/wrong section... this is my first post.
Please help me out here...
Thanks in advance,
Mihir
zaxxon
2
Everything is fine, just use code tags when you post code, data or logs etc. thanks
If "DEF=234" is the only identifier to match, you can try:
sed 's/^DEF=234/#&/' infile
I dont want starts with, i want it to be something like,
I want to search 234 value and append # to the same line which contains the string 234
for instance
ABC=123
DEF=234
EFG=2356
DFGT=234
should be updated to
ABC=123
#DEF=234
EFG=2356
#DFGT=234
Can you help me out on this?
Sorry for the confusion earlier... It seems i failed to phrase the proper query.
$ nawk '{if ($0~/234/) {print "#"$0}else {print $0}}' infile
zaxxon
5
No worries, I think I missed that point^^
sed 's/.*234.*/#&/' infile
ABC=123
#DEF=234
EFG=2356
#DFGT=234
Edit:
And the awk line a tad shorter:
awk '/234/ {print "#"$0; next}1' infile
$ perl -lane 'if($_ =~ /234/){print "#$_";}else{print $_}' test
ABC=123
#DEF=234
EFG=2356
#DFGT=234
sed '/234/s/^/#/' infile
awk '/234/{$0="#"$0}1' infile