I am trying to solve an optimization problem and to find the most efficient way of performing the following commands:
whois -> sed -> while (exit while) ->perform action
while loop currently look like
while [x eq smth]; do
x=$((x+1))
done
some action
Maybe it is more efficient to have while true with an if inside (if clause the same as for while). Also, what is the best case using bash to evaluate the time required for every single step?
sed(or any other child process) is probably your main overhead, rewriting the loop is unlikely to make a significant difference. Consider using shell expansion instead ofsed, or write the whole lot inawk, or maybe evenperlif you have complex code.