From: <Saved by Blink>
Snapshot-Content-Location: https://sastricks.com/unix/cl.txt
Subject:
Date: Thu, 13 Feb 2025 12:17:18 -0700
MIME-Version: 1.0
Content-Type: multipart/related;
type="text/html";
boundary="----MultipartBoundary--
HxI3BmAF0OYVelFRakNK5p3DPMosXa7D5qlNoofixk----"
------MultipartBoundary--HxI3BmAF0OYVelFRakNK5p3DPMosXa7D5qlNoofixk----
Content-Type: text/html
Content-ID: <[email protected]>
Content-Transfer-Encoding: binary
Content-Location: https://sastricks.com/unix/cl.txt
<html><head><meta http-equiv="Content-Type" content="text/html; charset=windows-
1252"><meta name="color-scheme" content="light dark"></head><body><pre style="word-
wrap: break-word; white-space: pre-wrap;">#!/usr/bin/bash
###################################################################################
# Script name: cl
#
# This shell script scan .lst or .out files for proc compare results
#
# example:
# > cl
# - No parameter will scan all .lst files in current directory
# > cl t_demog.lst
# > cl *.lst
# > cl t_*.lst
# > cl -f alllsts.txt
# -f flag to provide list of lst files in file
# -h flag to display help
#
# Author: Sarwan Singh
###################################################################################
ext=lst
# check for argument value
if [ "$1" = "-h" ] || [ "$1" = "" ]; then
echo -e "\n\nExample:\n>cl t_demog.lst"
echo ">cl *.lst"
echo ">cl \$myprog (list of program names without .sas)"
echo ">cl t_*.lst"
echo ">cl -f alllsts.txt"
echo " -f flag to provide list of lst files in file"
echo " -h flag to display help"
exit 0;
elif [ "$1" = "-f" ]; then
if [ "$2" = "" ]; then
echo "\nERROR: Specify a filename with list of lst files after -f."
echo "For help use: cl -h"
echo "Exiting script.\n"
exit 0;
else
#stop if infile does not exit
if [ ! -e $infile ]; then
echo "\nERROR: '$infile' does not exist."
echo "Exiting script.\n"
exit 0;
else
allfiles=`more $infile`
fi
fi
elif [ "$1" = "" ]; then
allfiles=`ls -al *.$ext | grep ^- | awk '{print $9}'`
else
allfiles=$*
fi
### Find longest filename for printng format
maxlen=0;
for file in ${allfiles[@]}
do
filelen=`echo ${#file}`
if [ ${maxlen} -lt ${filelen} ]; then
maxlen=$filelen
fi
done
### check lsts
for file in ${allfiles[@]}
do
ext=${file##*.}
if [ $file == $ext ]; then
if [[ "$file" == "v_o_"* ]]; then
ext=out
else
ext=lst
fi
file=$file.$ext
fi
printf "Checking: ${file}"
filelen=`echo ${#file}`
perl -e "print '.' x ($maxlen+5-$filelen);"
if [ ! -e $file ]; then
printf ":'$file' does not exist.\n"
elif [ -d $file ]; then
printf ":'$file' is directory.\n"
elif [ -f $file ]; then
checkfl=`checklst ${file}`
if [ "$checkfl" = "" ]; then
printf ":PASS\n"
else
printf ":FAILED******\n"
fi
fi
done
</pre></body></html>
------MultipartBoundary--HxI3BmAF0OYVelFRakNK5p3DPMosXa7D5qlNoofixk------