Use awk
em vez
$ cat ip.txt
# Allow from All
# Require all granted
# # Apache 2.2
# Require all granted
# Order Allow,Deny
# Require all granted
# Order Deny
$ awk '/#[[:space:]]*Require all granted/ && ++c==1{sub("#", " ")} 1' ip.txt
# Allow from All
Require all granted
# # Apache 2.2
# Require all granted
# Order Allow,Deny
# Require all granted
# Order Deny
$ awk '/#[[:space:]]*Require all granted/ && ++c==2{sub("#", " ")} 1' ip.txt
# Allow from All
# Require all granted
# # Apache 2.2
Require all granted
# Order Allow,Deny
# Require all granted
# Order Deny
$ awk '/#[[:space:]]*Require all granted/ && ++c>1{sub("#", " ")} 1' ip.txt
# Allow from All
# Require all granted
# # Apache 2.2
Require all granted
# Order Allow,Deny
Require all granted
# Order Deny
Veja também awk salvar modificações no lugar
Ou usando perl
$ # for inplace editing, use perl -i -pe
$ perl -pe 's/#/ / if /#\s*Require all granted/ && ++$c==1' ip.txt
# Allow from All
Require all granted
# # Apache 2.2
# Require all granted
# Order Allow,Deny
# Require all granted
# Order Deny