Need to read the values of a config file from a shell script -
i have shell script , mutual configuration file generic path, username , other values stored. want value configuration file while running sh script.
example:
sample.conf pt_user_name=>xxxx pt_passwd=>junly@2014 jrnl_source_folder=>x/y/v pt_source_folder=>/x/y/r/g css_source_folder=>/home/d/g/h
now want thing in sh script.
cd $css_source_folder
this command within shell script should take me location d/g/h while script running.
is there way accomplish other grep , awk??
thanks rinu
if want read conf file everytime grep , cutting might help you,
suppose need value css_source_folder property prop1="css_source_folder" (i assuming know property name value want)
value_of_prop1=`grep $prop1 sample.conf| cutting -f2 -d "=" | cutting -f2 -d ">"`
like,
[db2inst2@pegdb2 ~]$ vi con.conf [db2inst2@pegdb2 ~]$ grep css_source_folder con.conf css_source_folder=>/home/d/g/h [db2inst2@pegdb2 ~]$ value=`grep css_source_folder con.conf | cutting -f2 -d "="` [db2inst2@pegdb2 ~]$ echo $value >/home/d/g/h [db2inst2@pegdb2 ~]$ value=`grep css_source_folder con.conf | cutting -f2 -d "=" | cutting -f2 -d ">"` [db2inst2@pegdb2 ~]$ echo $value /home/d/g/h
if want read properties @ once, apply loop , solve purpose
shell configuration-files
No comments:
Post a Comment