#!/usr/bin/ksh

##  Remove cells from a cell list file.
##  Usage:  cat remvcellist | removecell cellistfile
##
##  First created:   Jian-Guo Li    29 Apr 2022
##  Last modified:   Jian-Guo Li     6 Jan 2023
##

# Check cell list file name on command line. 
 if [ 0$# -ge 1 ]
   then
   cellist=$1
 else
   echo " No cell list file is provided! "
   exit 1
 fi

 cp $cellist templist

##  Read the whole line literally without removing any space.
while IFS= read -r fff
do
##  To display the whole line without squeezing the white spaces.
echo "$fff"
first16=`expr substr "$fff" 1 16 `
##  Because $fff contains spaces, they have to be quoted as one string.
## echo  "$first16"
sed "/$first16/d" templist > tempc1
mv tempc1 templist
done

exit 0

