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

Help needed to print the not updated files in the Directory

$
0
0
Hi All,

I have written one program to print the files which are not updated in the specified directory in .Dat file. If I am executing the same command in the command prompt its working fine but if I am executing in shell script it's not working fine. Please correct if any thing wrong in the below script

My requirement is, I want the files which are not updated in last 7 days

Code:

#set -vx
#!/bin/ksh

day_chk=`expr $(nzsql -host ${NZ_HOST} -db ${NZ_DATABASE_LOG}  -A -t -c "SELECT TO_CHAR(CURRENT_DATE,'DD')") - 7`
mon_chk=`expr $(nzsql -host ${NZ_HOST} -db ${NZ_DATABASE_LOG}  -A -t -c "SELECT TO_CHAR(CURRENT_DATE,'Mon')")`

echo "day_chk " $day_chk
echo "mon_chk " $mon_chk
echo $DIR_DATATGT_BPS


ls -ltr ${DIR_DATATGT_BPS}/*.lst | awk '$7 < $day_chk && $6 == "$mon_chk" { print $9 }' > ${DIR_TEMP}/Non_Updated_Files.dat

file_count=`cat ${DIR_TEMP}/Non_Updated_Files.dat | wc -l`
echo "File Count :"$file_count

Please let me know what is the issue in that code.

example

Code:

-rwxr-xr-x  1 chandu cvcinfm  5956 Nov 2 03:40 file1.ksh
-rwxrwxrwx  1 chandu cvcinfm  5432 Nov 2 03:52 file2.ksh
-rwxr-xr-x  1 chandu cvcinfm  3147 Nov 16 16:58 file3.ksh

i want to print

file1.ksh
file2.ksh in my output file


Thanks,
Chandu.

Viewing all articles
Browse latest Browse all 16232

Trending Articles