0% found this document useful (0 votes)
2 views

sastricks.com_unix_cl

The document contains a shell script named 'cl' designed to scan .lst or .out files for procedure comparison results. It provides various command-line options for users to specify files or directories to scan, including help and file list functionalities. The script checks the existence and type of specified files, reporting the results of the checks accordingly.

Uploaded by

zackm198613
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

sastricks.com_unix_cl

The document contains a shell script named 'cl' designed to scan .lst or .out files for procedure comparison results. It provides various command-line options for users to specify files or directories to scan, including help and file list functionalities. The script checks the existence and type of specified files, reporting the results of the checks accordingly.

Uploaded by

zackm198613
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3

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:
# &gt; cl
# - No parameter will scan all .lst files in current directory
# &gt; cl t_demog.lst
# &gt; cl *.lst
# &gt; cl t_*.lst
# &gt; 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&gt;cl t_demog.lst"
echo "&gt;cl *.lst"
echo "&gt;cl \$myprog (list of program names without .sas)"
echo "&gt;cl t_*.lst"
echo "&gt;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------

You might also like