krdgroup23
New Member
Hello everyone! I am writing script which must count amount of strings in files .z format. Name of folder can changes in dependence of current date, if it's 1-st date of the month script count amount in folder which is called 2210 (previous month ) if today is not 1-st day of month then folder is called 2211 (current month). For ex. I have catalogs with files:
here is my script
it shows
How should i change my script that the result will
Code:
WORK6\AXE\CNA5\LBN\2211\1.z # 16 strings in file
WORK6\AXE\TELLIN\2211\2.z # 16 strings in file
WORK6\AXE\TELLIN\2211\3.z # 16 strings in file
here is my script
Code:
#!/bin/bash
#assign a value to the variable
timestamp=$(date +%d)
#if today is 1-st date of month then previous month else current
if [[ $timestamp == 01 ]]; then
folder=$(date -d " - $(date +%d) days" +%y%m)
else
folder=$(date +%y%m)
fi
#find path to files
path=$(find ./ -type d -name "$folder")
#find files and count amount of strings
for file in $path/*
do
$(zcat $file | wc –l)
done
it shows
Code:
wc: –l: No such file or directory
gzip: ./AXE/CNA5/LBN/2211 is a directory -- ignored
wc: –l: No such file or directory
wc: –l: No such file or directory
How should i change my script that the result will
Code:
16 WORK6\AXE\CNA5\LBN # 16 strings in file 1.z
32 WORK6\AXE\TELLIN # 32 strings in files 2.z+3.z