#!/bin/bash # This is the part of my script which has been causing problems for me. # I know it does not work at all, but it gives you a picture of what I # am trying to do. # $1 = source file 1 # $2 = source file 2 # $3 = output file TABLE_FORMAT="%-35s%8s\n" IFS=" " for CLASS in notebook videocard soundcard wifi ethernet-card \ sd-card-reader webcam bluetooth acquisition-card 3G-card \ host-controller fingerprint-reader RAID-adapter modem printer \ scanner do DEVICE_NAMES=$( cat $2 | grep $CLASS | sed -e "s/^$CLASS //" ) # sed -e /\'/d -e /\(/d -e /\)/d -e /\[/d -e /\]/d for NAME in "${DEVICE_NAMES[*]}" do NUM=$( cat $1 | grep $NAME | wc -l) let "TOTAL=$TOTAL+$NUM" done printf $TABLE_FORMAT $CLASS $NUM >> $3 NUM=0 done printf $TABLE_FORMAT "Total" $TOTAL >> $3