Reading Properties file [message #248966] |
Tue, 03 July 2007 00:09 |
manchalravi
Messages: 15 Registered: June 2007
|
Junior Member |
|
|
Hi,
I am ne to Shell scripting. In my requirement I need to read certain values from a properties find and assing them to variables in shell script. Can you please let me know, how can this be done.
Property file includes:
Properties.cfg
basedir=/home/teuser/logs
archivedays=7
delete_archive=30
in my shell script I need to read above assing them to variables dynamicaly exactly like above.
Thanks in advance for the solution
Regards,
Ravi
|
|
|
|
|
Re: Reading Properties file [message #249165 is a reply to message #248975] |
Tue, 03 July 2007 09:51 |
DreamzZ
Messages: 1666 Registered: May 2007 Location: Dreamzland
|
Senior Member |
|
|
Do you want to delete old files basis on some criteria?
ie you want to delete all oldest files but not new 40 files.
or
you want to delete files generated sydate - 3.. or explain bit more...
set DAY=`date|nawk '{print $3}'`
set DIR1=/u500/oracle/mydb/oraarc
foreach lg (`ls ${DIR1} | grep arc | grep -v Z`)
set FILE_DATE=`ls -l ${DIR1}/${lg} |nawk '{print $7}'`
if ( ${DAY} != ${FILE_DATE} ) then
rm ${DIR1}/${lg}
endif
end
[Updated on: Tue, 03 July 2007 09:53] Report message to a moderator
|
|
|
Re: Reading Properties file [message #249217 is a reply to message #249165] |
Tue, 03 July 2007 12:03 |
andrew again
Messages: 2577 Registered: March 2000
|
Senior Member |
|
|
host1:abc>>cat Properties.cfg
#this is a comment
#basedir=/home/abc
basedir=/home/teuser/logs
basedir2=/tmp
archivedays=7
delete_archive=30
host1:abc>>cat t.ksh
#LST=`egrep -w "basedir|archivedays|delete_archive" Properties.cfg | grep -v "#" | xargs`
LST=`egrep -w "^basedir|^archivedays|^delete_archive" Properties.cfg | xargs`
for VAR in $LST
do
export $VAR
done
echo "basedir $basedir"
echo "archivedays $archivedays"
echo "delete_archive $delete_archive"
host1:abc>>t.ksh
basedir /home/teuser/logs
archivedays 7
delete_archive 30
|
|
|