Quantcast
Channel: UNIX and Linux Forums
Viewing all articles
Browse latest Browse all 16232

Help! Need "File exist check" and line count

$
0
0
Hello,

I've been stuck with this for a few days now :wall:, so I'm hoping someone out there might be kind enough to help me.

I need to do a "file exist" check with a variable in the file name. After that I need to do a line count on the file, and output its results to a txt file.

For simplicity/compliance reasons, I have simplified all my paths and file names. Also the txt file has already been created, hence the ">>" instead of ">"

Right now I'm getting a "bad substitute" error for the first line "if [ -f "/path/File_${CUR_DATE).rtf" ]; then" in the code below.



Code:
#!/bin/ksh

HOMEDIR= "/mypath"
YEST_DATE=$(TZ=EST+24 date +%Y%m%d)
CUR_DATE=$(date "+%Y%m%d")

if [ -f "/path/File_${CUR_DATE).rtf" ]; then
echo "file found with today's date" >> $HOMEDIR/file.txt
echo " " >> $HOMEDIR/file.txt
echo "Records in file:" >> $HOMEDIR/file.txt
echo wc -l < "/path/File_${CUR_DATE)" >> $HOMEDIR/file.txt
elif [ -f "/path/File_${YEST_DATE).rtf" ]; then
echo "file found with yesterday's date" >> $HOMEDIR/file.txt
echo " " >> $HOMEDIR/file.txt
echo "Records in file:" >> $HOMEDIR/file.txt
echo wc -l < "/path/File_${YEST_DATE).rtf" >> $HOMEDIR/file.txt
else
echo "file not found" >> $HOMEDIR/file.txt

fi


Please someone grace me with their expertise, it is very much appreciated!

Best regards,

Jay

Viewing all articles
Browse latest Browse all 16232

Trending Articles