Home » Infrastructure » Unix » Reading Properties file
Reading Properties file [message #248966] Tue, 03 July 2007 00:09 Go to next message
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 #248972 is a reply to message #248966] Tue, 03 July 2007 00:25 Go to previous messageGo to next message
BlackSwan
Messages: 26766
Registered: January 2009
Location: SoCal
Senior Member
I wonder what this question has to do with Oracle.
Re: Reading Properties file [message #248975 is a reply to message #248972] Tue, 03 July 2007 00:30 Go to previous messageGo to next message
manchalravi
Messages: 15
Registered: June 2007
Junior Member
Hi,

This is posted in UNIX section. I havent told that its related to oracle. Cant I post the problem on UNIX?

Please give me a solution.

Regards,
Ravi
Re: Reading Properties file [message #249165 is a reply to message #248975] Tue, 03 July 2007 09:51 Go to previous messageGo to next message
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 Go to previous message
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

Previous Topic: how to get oracle result in shell variable
Next Topic: UNIX- How two compare a file on a local system and remote system
Goto Forum:
  


Current Time: Fri Nov 22 04:02:52 CST 2024