Wednesday, April 19, 2023

how to skip commented lines in linux in loop for shell script.

How to skip commented input lines from a input file in loop in Linux script:
 
below is the simple code with small example:


#!/bin/ksh
# Script to check required ORACLE - RHEL RPMs:
#
while read rpm_c
  do
case "$rpm_c" in \#*) continue ;; esac
rpm_check=`rpm -qa $rpm_c | wc -l`
if [[ $rpm_check != 0 ]]; then
rpm_check=YES
echo $'\e[1;36m' rpm: $'\e[1;34m' $rpm_c   $'\e[1;32m' $rpm_check $'\e[0m'
else
rpm_check=NO
echo $'\e[1;36m' rpm: $'\e[1;34m' $rpm_c  $'\e[1;31m'  $rpm_check $'\e[0m'
fi
done<RHEL-7_ORACLE19C_RPMS.log


input in the logfile:


libgcc
libstdc++
libstdc++-devel
libxcb
make
smartmontools
sysstat
#
#Optional Packages for Red Hat Enterprise Linux 7:
#
#ipmiutil (for Intelligent Platform Management Interface)
#net-tools (for Oracle RAC and Oracle Clusterware)
#nfs-utils (for Oracle ACFS)
#python (for Oracle ACFS Remote)

No comments:

Post a Comment

PostgreSql: Useful Commands-

 1)   ************************* Users ***************************  -- List of users with roles assigned: SELECT usename AS role_name,   CASE...