dayankoven
Programmer
Hi there fellow gurus,
I have 3 files in the directory.
Test_Append_Time20021011123500.DAT
Test_Append_Time20021011123501.DAT
Test_Append_Time20021011143500.DAT
I'm written a script that will scan a directory looking for files with particular pattern ("Test_Append_Time" and replace "Test_Append_Time" with 1001. The end result will look like:-
100120021011123500.DAT
100120021011123501.DAT
100120021011143500.DAT
Once i've done that, I need to sum up the total number,X of records that is 1001*00 and also total number,Y which is 1001*01. Then i need to do a computation for Z = X+Y-1. Then i need to return Z which in this case would total "2" back.
I've managed to list the total X and Y on the screen but don't know how to store them in variable/strings. Can fellow forummers please help me..? Thanks in advance
My code looks something like :-
#!/usr/bin/sh
oldPREF="Test_Append_Time"
newPREF="1001"
for file in ${oldPREF}*
do
mv "${file}" "${newPREF}${file#${oldPREF}}"
ls ${newPREF}*00.DAT|grep -v '^d|^total'| wc -l
ls ${newPREF}*01.DAT|grep -v '^d|^total'| wc -l
done
I have 3 files in the directory.
Test_Append_Time20021011123500.DAT
Test_Append_Time20021011123501.DAT
Test_Append_Time20021011143500.DAT
I'm written a script that will scan a directory looking for files with particular pattern ("Test_Append_Time" and replace "Test_Append_Time" with 1001. The end result will look like:-
100120021011123500.DAT
100120021011123501.DAT
100120021011143500.DAT
Once i've done that, I need to sum up the total number,X of records that is 1001*00 and also total number,Y which is 1001*01. Then i need to do a computation for Z = X+Y-1. Then i need to return Z which in this case would total "2" back.
I've managed to list the total X and Y on the screen but don't know how to store them in variable/strings. Can fellow forummers please help me..? Thanks in advance
My code looks something like :-
#!/usr/bin/sh
oldPREF="Test_Append_Time"
newPREF="1001"
for file in ${oldPREF}*
do
mv "${file}" "${newPREF}${file#${oldPREF}}"
ls ${newPREF}*00.DAT|grep -v '^d|^total'| wc -l
ls ${newPREF}*01.DAT|grep -v '^d|^total'| wc -l
done