I am running this command
awk '{print "Removing " ORS $0;system("rm " $0 ORS " if [ $? -eq 0 ]" ORS "then" ORS "echo file " $0 " has been removed." ORS "fi")}' <(cat /tmp/findo)
On bash and the command works however when executed from a shell script it throws the underlying error
Here is the example and you may look at the 'line 23 error'
# sh -x rvarlog_util.sh
+ findout=/tmp/findout
+ '[' -e /tmp/findout ']'
++ du -sm /var/log
++ awk '{print $1+0}'
+ cdu=2372
++ awk '{print $1+0}'
++ grep total
++ du -m --max-depth=1 -c -m -x /var/log/messages /var/log/messages-20190310 /var/log/messages-20190323-1553338190.gz /var/log/messages-20190324-1553424406.gz /var/log/messages-20190324-1553456095.gz /var/log/messages-20190324-1553456293.gz /var/log/messages-20190324-1553457237.gz /var/log/messages-20190324-1553457268.gz /var/log/maillog-20190324-1553456095.gz /var/log/boot.log /var/log/audit/audit.log /var/log/audit/audit.log-20190311-1552325090.gz /var/log/puppetlabs
+ fusage=2258
rvarlog_util.sh: line 23: syntax error near unexpected token `('
rvarlog_util.sh: line 23: `awk '{print "Removing " ORS $0;system("rm " $0 ORS " if [ $? -eq 0 ]" ORS "then" ORS "echo file " $0 " has been removed." ORS "fi")}' <(cat /tmp/findo)'