Replace deprecated 'egrep' commands with 'grep -E'. (#12306)

Co-authored-by: Sander Grendelman <sander.grendelman@axians.com>
diff --git a/plugins/hypervisors/kvm/src/main/java/org/apache/cloudstack/utils/linux/KVMHostInfo.java b/plugins/hypervisors/kvm/src/main/java/org/apache/cloudstack/utils/linux/KVMHostInfo.java
index db665c7..e88981f 100644
--- a/plugins/hypervisors/kvm/src/main/java/org/apache/cloudstack/utils/linux/KVMHostInfo.java
+++ b/plugins/hypervisors/kvm/src/main/java/org/apache/cloudstack/utils/linux/KVMHostInfo.java
@@ -140,7 +140,7 @@
         long speed = 0L;
         LOGGER.info("Fetching CPU speed from command \"lscpu\".");
         try {
-            String command = "lscpu | grep -i 'Model name' | head -n 1 | egrep -o '[[:digit:]].[[:digit:]]+GHz' | sed 's/GHz//g'";
+            String command = "lscpu | grep -i 'Model name' | head -n 1 | grep -E -o '[[:digit:]].[[:digit:]]+GHz' | sed 's/GHz//g'";
             if(isHostS390x()) {
                 command = "lscpu | grep 'CPU dynamic MHz' | cut -d ':' -f 2 | tr -d ' ' | awk '{printf \"%.1f\\n\", $1 / 1000}'";
             }
diff --git a/plugins/hypervisors/ovm3/src/test/resources/scripts/clean_primary.sh b/plugins/hypervisors/ovm3/src/test/resources/scripts/clean_primary.sh
index bbf1cd0..5086a16 100755
--- a/plugins/hypervisors/ovm3/src/test/resources/scripts/clean_primary.sh
+++ b/plugins/hypervisors/ovm3/src/test/resources/scripts/clean_primary.sh
@@ -17,7 +17,7 @@
 # specific language governing permissions and limitations
 # under the License.
 #
-for i in `xm list | awk '{ print $1 }' | egrep -v "Name|Domain-0"`
+for i in `xm list | awk '{ print $1 }' | grep -E -v "Name|Domain-0"`
 do
     xm destroy $i
 done
diff --git a/plugins/hypervisors/ovm3/src/test/resources/scripts/clean_secondary.sh b/plugins/hypervisors/ovm3/src/test/resources/scripts/clean_secondary.sh
index 4275ee8..3d51339 100755
--- a/plugins/hypervisors/ovm3/src/test/resources/scripts/clean_secondary.sh
+++ b/plugins/hypervisors/ovm3/src/test/resources/scripts/clean_secondary.sh
@@ -17,7 +17,7 @@
 # specific language governing permissions and limitations
 # under the License.
 #
-for i in `xm list | awk '{ print $1 }' | egrep -v "Name|Domain-0"`
+for i in `xm list | awk '{ print $1 }' | grep -E -v "Name|Domain-0"`
 do
     xm destroy $i
 done
diff --git a/scripts/storage/multipath/connectVolume.sh b/scripts/storage/multipath/connectVolume.sh
index fb8387e..1e20526 100755
--- a/scripts/storage/multipath/connectVolume.sh
+++ b/scripts/storage/multipath/connectVolume.sh
@@ -100,7 +100,7 @@
 done
 
 echo "$(date): Doing a recan to make sure we have proper current size locally"
-for device in $(multipath -ll 3${WWID} | egrep '^  ' | awk '{print $2}'); do
+for device in $(multipath -ll 3${WWID} | grep -E '^  ' | awk '{print $2}'); do
     echo "1" > /sys/bus/scsi/drivers/sd/${device}/rescan;
 done
 
diff --git a/scripts/storage/multipath/resizeVolume.sh b/scripts/storage/multipath/resizeVolume.sh
index 1b44a71..491c1bd 100755
--- a/scripts/storage/multipath/resizeVolume.sh
+++ b/scripts/storage/multipath/resizeVolume.sh
@@ -51,7 +51,7 @@
 
 logger -t "CS_SCSI_VOL_RESIZE" "${WWID} resizing disk path at /dev/mapper/3${WWID} STARTING"
 
-for device in $(multipath -ll 3${WWID} | egrep '^  ' | awk '{print $2}'); do
+for device in $(multipath -ll 3${WWID} | grep -E '^  ' | awk '{print $2}'); do
     echo "1" > /sys/bus/scsi/drivers/sd/${device}/rescan;
 done
 
diff --git a/scripts/util/keystore-setup b/scripts/util/keystore-setup
index 1e1237c..88f5a87 100755
--- a/scripts/util/keystore-setup
+++ b/scripts/util/keystore-setup
@@ -75,7 +75,7 @@
 # Generate CSR
 $LOGGER_CMD "Generating CSR"
 [ -f "$CSR_FILE" ] && rm -f "$CSR_FILE"
-addresses=$(ip address | grep inet | awk '{print $2}' | sed 's/\/.*//g' | grep -v '^169.254.' | grep -v '^127.0.0.1' | egrep -v '^::1|^fe80' | grep -v '^::1' | sed 's/^/ip:/g' | tr '\r\n' ',')
+addresses=$(ip address | grep inet | awk '{print $2}' | sed 's/\/.*//g' | grep -v '^169.254.' | grep -v '^127.0.0.1' | grep -E -v '^::1|^fe80' | grep -v '^::1' | sed 's/^/ip:/g' | tr '\r\n' ',')
 $LOGGER_CMD "Found following SAN addresses to add to CSR: ${addresses}"
 keytool -certreq -storepass "$KS_PASS" -alias "$ALIAS" -file "$CSR_FILE" -keystore "$KS_FILE" -ext san="$addresses" 2>&1 | $LOGGER_CMD
 if [ $? -ne 0 ];then
diff --git a/scripts/vm/network/ovs-pvlan-kvm-vm.sh b/scripts/vm/network/ovs-pvlan-kvm-vm.sh
index c8da75f..b28dbda 100755
--- a/scripts/vm/network/ovs-pvlan-kvm-vm.sh
+++ b/scripts/vm/network/ovs-pvlan-kvm-vm.sh
@@ -112,7 +112,7 @@
 }
 
 # try to find the physical link to outside, only supports eth and em prefix now
-trunk_port=`ovs-ofctl show $br | egrep "\((eth|em)[0-9]" | cut -d '(' -f 1|tr -d ' '`
+trunk_port=`ovs-ofctl show $br | grep -E "\((eth|em)[0-9]" | cut -d '(' -f 1|tr -d ' '`
 vm_port=$(find_port $vm_mac)
 
 # craft the vlan headers. Adding 4096 as in hex, it must be of the form 0x1XXX
diff --git a/scripts/vm/network/ovs-pvlan-vm.sh b/scripts/vm/network/ovs-pvlan-vm.sh
index 95054c8..b55377f 100755
--- a/scripts/vm/network/ovs-pvlan-vm.sh
+++ b/scripts/vm/network/ovs-pvlan-vm.sh
@@ -87,7 +87,7 @@
 fi
 
 # try to find the physical link to outside, only supports eth and em prefix now
-trunk_port=`ovs-ofctl show $br | egrep "\((eth|em)[0-9]" | cut -d '(' -f 1|tr -d ' '`
+trunk_port=`ovs-ofctl show $br | grep -E "\((eth|em)[0-9]" | cut -d '(' -f 1|tr -d ' '`
 
 if [ "$op" == "add" ]
 then
diff --git a/server/src/main/java/com/cloud/server/StatsCollector.java b/server/src/main/java/com/cloud/server/StatsCollector.java
index a0d9c09..abc2257 100644
--- a/server/src/main/java/com/cloud/server/StatsCollector.java
+++ b/server/src/main/java/com/cloud/server/StatsCollector.java
@@ -986,7 +986,7 @@
             double totalcpucap = 0;
             if (StringUtils.isEmpty(cpucaps)) {
                 String totalCpus = Script.runSimpleBashScript("nproc --all| tr '\\n' \" \"");
-                String maxCpuSpeed = Script.runSimpleBashScript("lscpu | egrep 'CPU max MHz' | head -1 | cut -f 2 -d : | tr -d ' '| tr '\\n' \" \"");
+                String maxCpuSpeed = Script.runSimpleBashScript("lscpu | grep -E 'CPU max MHz' | head -1 | cut -f 2 -d : | tr -d ' '| tr '\\n' \" \"");
                 if (StringUtils.isNotEmpty(totalCpus) && StringUtils.isNotEmpty(maxCpuSpeed)) {
                     totalcpucap = Double.parseDouble(totalCpus) * Double.parseDouble(maxCpuSpeed);
                 }
diff --git a/systemvm/agent/scripts/ssvm-check.sh b/systemvm/agent/scripts/ssvm-check.sh
index f5d69cb..86cecb7 100755
--- a/systemvm/agent/scripts/ssvm-check.sh
+++ b/systemvm/agent/scripts/ssvm-check.sh
@@ -41,7 +41,7 @@
 
 # ping dns server
 echo ================================================
-DNSSERVER=`egrep '^nameserver' /etc/resolv.conf  | awk '{print $2}'| head -1`
+DNSSERVER=`grep -E '^nameserver' /etc/resolv.conf  | awk '{print $2}'| head -1`
 echo "First DNS server is " $DNSSERVER
 ping -c 2  $DNSSERVER
 if [ $? -eq 0 ]
diff --git a/systemvm/debian/opt/cloud/bin/update_interface_config.sh b/systemvm/debian/opt/cloud/bin/update_interface_config.sh
index 53d81f7..427d5d9 100755
--- a/systemvm/debian/opt/cloud/bin/update_interface_config.sh
+++ b/systemvm/debian/opt/cloud/bin/update_interface_config.sh
@@ -31,7 +31,7 @@
   for i in `seq 1 $(($timeout))`
   do
     #inf=$(ip route list ${1}/${2} | awk '{print $3}')
-    inf=$(ip addr show|egrep '^ *inet'|grep ${1}/${2} |grep brd|awk -- '{ print $NF; }')
+    inf=$(ip addr show|grep -E '^ *inet'|grep ${1}/${2} |grep brd|awk -- '{ print $NF; }')
     if [ ! -z $inf ]; then
       echo $inf
       break
diff --git a/test/integration/component/test_multiple_subnets_in_isolated_network.py b/test/integration/component/test_multiple_subnets_in_isolated_network.py
index 278728b..f5efd9a 100644
--- a/test/integration/component/test_multiple_subnets_in_isolated_network.py
+++ b/test/integration/component/test_multiple_subnets_in_isolated_network.py
@@ -210,9 +210,9 @@
             self.logger.debug("Skip as redundant_state is %s" % redundant_state)
             return
         elif redundant_state == "PRIMARY":
-            command = 'ip link show |grep BROADCAST | egrep "%s" |grep "state DOWN" |wc -l' % publicNics
+            command = 'ip link show |grep BROADCAST | grep -E "%s" |grep "state DOWN" |wc -l' % publicNics
         elif redundant_state == "BACKUP":
-            command = 'ip link show |grep BROADCAST | egrep "%s" |grep "state UP" |wc -l' % publicNics
+            command = 'ip link show |grep BROADCAST | grep -E "%s" |grep "state UP" |wc -l' % publicNics
         result = get_process_status(
             host.ipaddress,
             host.port,
diff --git a/test/integration/component/test_multiple_subnets_in_isolated_network_rvr.py b/test/integration/component/test_multiple_subnets_in_isolated_network_rvr.py
index d83571f..b6c6434 100644
--- a/test/integration/component/test_multiple_subnets_in_isolated_network_rvr.py
+++ b/test/integration/component/test_multiple_subnets_in_isolated_network_rvr.py
@@ -210,9 +210,9 @@
             self.logger.debug("Skip as redundant_state is %s" % redundant_state)
             return
         elif redundant_state == "PRIMARY":
-            command = 'ip link show |grep BROADCAST | egrep "%s" |grep "state DOWN" |wc -l' % publicNics
+            command = 'ip link show |grep BROADCAST | grep -E "%s" |grep "state DOWN" |wc -l' % publicNics
         elif redundant_state == "BACKUP":
-            command = 'ip link show |grep BROADCAST | egrep "%s" |grep "state UP" |wc -l' % publicNics
+            command = 'ip link show |grep BROADCAST | grep -E "%s" |grep "state UP" |wc -l' % publicNics
         result = get_process_status(
             host.ipaddress,
             host.port,
diff --git a/test/integration/component/test_multiple_subnets_in_vpc.py b/test/integration/component/test_multiple_subnets_in_vpc.py
index 9167f15..0206659 100644
--- a/test/integration/component/test_multiple_subnets_in_vpc.py
+++ b/test/integration/component/test_multiple_subnets_in_vpc.py
@@ -214,9 +214,9 @@
             self.logger.debug("Skip as redundant_state is %s" % redundant_state)
             return
         elif redundant_state == "PRIMARY":
-            command = 'ip link show |grep BROADCAST | egrep "%s" |grep "state DOWN" |wc -l' % publicNics
+            command = 'ip link show |grep BROADCAST | grep -E "%s" |grep "state DOWN" |wc -l' % publicNics
         elif redundant_state == "BACKUP":
-            command = 'ip link show |grep BROADCAST | egrep "%s" |grep "state UP" |wc -l' % publicNics
+            command = 'ip link show |grep BROADCAST | grep -E "%s" |grep "state UP" |wc -l' % publicNics
         result = get_process_status(
             host.ipaddress,
             host.port,
diff --git a/test/integration/component/test_multiple_subnets_in_vpc_rvr.py b/test/integration/component/test_multiple_subnets_in_vpc_rvr.py
index 7c71273..e8963f1 100644
--- a/test/integration/component/test_multiple_subnets_in_vpc_rvr.py
+++ b/test/integration/component/test_multiple_subnets_in_vpc_rvr.py
@@ -214,9 +214,9 @@
             self.logger.debug("Skip as redundant_state is %s" % redundant_state)
             return
         elif redundant_state == "PRIMARY":
-            command = 'ip link show |grep BROADCAST | egrep "%s" |grep "state DOWN" |wc -l' % publicNics
+            command = 'ip link show |grep BROADCAST | grep -E "%s" |grep "state DOWN" |wc -l' % publicNics
         elif redundant_state == "BACKUP":
-            command = 'ip link show |grep BROADCAST | egrep "%s" |grep "state UP" |wc -l' % publicNics
+            command = 'ip link show |grep BROADCAST | grep -E "%s" |grep "state UP" |wc -l' % publicNics
         result = get_process_status(
             host.ipaddress,
             host.port,