Listing Lists

A mini project is to hand over the course packages for the prior product to each of our clients. A good idea was to include a list of the files so down the road, if something is missing then, we can say this list in the ticket has what you received.

So I wrote this shell script to make the lists for me. (Well, really the analyst doing the hard work wanted to know if he should make the list. Told him I could really easily through Linux.) This is because I am talking about 385,528 courses and 37 targets. First step generates a list of the clients (schools) involved. Next, the path to where the files are stored have two subdirectories, so I pull them out of the path. The list generates with a find command stripping out the “./” at the beginning and writing the results to a file. Finally I check the size and number of lines in the file.

SCHOOLLIST=`find /${BASEDIR} -name bak`
for SCHOOLDIR in $SCHOOLLIST
do
cd $SCHOOLDIR
SCHOOL=`pwd | awk -F\/ ‘{print $4}’`
CLUSTER=`pwd | awk -F\/ ‘{print $3}’`
find . -name “*.bak” | sed -e ‘s|^./||g’ > ${BASEDIR}/${CLUSTER}/${SCHOOL}/course_list_${SCHOOL}.txt
head /${BASEDIR}/${CLUSTER}/${SCHOOL}/course_list_${SCHOOL}.txt
done
ls -h /${BASEDIR}/*/*/course_list*
wc -l /${BASEDIR}/*/*/course_list*

Since each course is on its own line, I can compare these numbers to other known numbers of courses.

So nice to get the computer to work for me. Purely by hand this would have taken days. It took about half an hour to craft the core and make sure it looked right. Then another half hour for the loop to work right.

Of course, I need to figure out how to do this in Powershell. :)

from Rants, Raves, and Rhetoric v4Rants, Raves, and Rhetoric v4 »

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s