Hi
I want to write a script that will:
1- locate folder "store" on a *nix filesystem
2- move into that folder
3- print list of contents with last modification date
4- calculate sub-folders size
This folder's absolute path changes from server to server, but the folder name remains the same always.
There is a config file that contains the correct path to that folder though, but it doesn't give absolute path to it.
Sample Config:
Account ON
DIR-Store /hdd1
Scheduled YES
ِAccording to the config file the absolute path would be "/hdd1/backup/store/"
I need the script to grep the "/hdd1" or anything beyond the word "DIR-Store", add "/backup/store/" to it, move into folder "store", print list of its contents, and calculate the sub-folder's size.
Until now I manually edit the script on each server to reflect the path to the "store" folder.
Here is a sample script:
#!/bin/bash
echo " "
echo " "
echo "Moving Into Directory"
cd /hdd1/backup/store/
echo "Listing Directory Content"
echo " "
ls -alh
echo "*******************************"
sleep 2
echo " "
echo "Calculating Backup Size"
echo " "
du -sh store/*
echo "********** Done! **********"
I know I could use grep
cat /etc/store.conf | grep DIR-Store
I just don't know how to get around selecting the path, adding the "/backup/store/" and moving ahead.
Any help will be appreciated