I want to execute the for loop with sed command, and is getting an error for the same
for i in <comma-separated server name list>;do "command";echo $i;done
where command=sed '/^$/d' /home/nextag/instance.properties|grep -vc '#'
I'm getting the following error :- -bash: sed "/^$/d" /home/nextag/instance.properties|grep -vc
#: No such file or directory
lu1
What is the correct way to execute this command to get the perfect output
I tried this as well>> for i in lu1;do 'sed \'/^$/d\' /home/nextag/instance.properties|grep -vc \'#\'';echo $i;done
Also, can some explain the part '/^$/d'
in sed '/^$/d' /home/nextag/instance.properties|grep -vc '#'
This should work.
Below line is used to remove all the empty lines.
grep -vc '^\s*#'
will ignore the lines starting with # and gives the count of other lines.Hope this helps.