counter

Published: (January 12, 2026 at 10:17 AM EST)
1 min read
Source: Dev.to

Source: Dev.to

Counter Script

mkfifo counter.fifo

(
  t=0
  b=0
  while read cmd; do
    case "$cmd" in
      inc_t) ((t++)) ;;
      inc_b) ((b++)) ;;
      get)   echo "$t $b" ;;
    esac
  done  counter.fifo

  echo ""
  echo "Dumping table $tableName"
  echo ""

  bcpOUTToDir "$tableName"
  if [ $? -ne 0 ]; then
    echo inc_b > counter.fifo
    echo "ERROR: BCP OUT command failed for table $tableName"
  fi
) &

proceedWhenLessThanMaxJobs
done  counter.fifo
read t b < counter.fifo

echo "Total tables: $t"
echo "Failures: $b"

kill "$COUNTER_PID"
rm counter.fifo
Back to Blog

Related posts

Read more »

smart

bash !/bin/bash Usage: ./filter.sh file.csv decimals col1 col2 ... colN Example: ./filter.sh data.csv 2 45 if '$' -lt 3 ; then echo 'Usage: $0 file.csv decimals...

Sort by File Extension - Bash Script

Overview This Bash script organizes the contents of a directory by file extension. It creates a sorted_files folder inside the source directory and, for each d...

My Coding Rules for Bash Scripts

My Coding Rules for Bash Scripts !Cover image for My Coding Rules for Bash Scriptshttps://media2.dev.to/dynamic/image/width=1000,height=420,fit=cover,gravity=a...