- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Re: Manage parameter-file
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-13-2006 03:57 AM
тАО01-13-2006 03:57 AM
what is the best way to manage a parameter-file?
I have a file like this:
par1=value1
par2=value2 #comment
par3=value3
i have a menu and there is a menu-point which is called "set par1", when i choice this point comes a prompt where i can give the value for par1. after i give the value, how can i set this value in the parameter-file? and also read from the file?
Thanks
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-13-2006 03:58 AM
тАО01-13-2006 03:58 AM
Re: Manage parameter-file
it should be in ksh.
Regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-13-2006 04:03 AM
тАО01-13-2006 04:03 AM
Re: Manage parameter-file
par2=23
(
echo "par1=$par1"
echo "par2=$par2 #comment"
echo "par3=$par3"
) >yourparamfile
HTH
-- Rod Hills
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-15-2006 11:46 PM
тАО01-15-2006 11:46 PM
Re: Manage parameter-file
what is the best way to read one value from the parameter-file?
and something other:
what means "set -x"?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-15-2006 11:56 PM
тАО01-15-2006 11:56 PM
Re: Manage parameter-file
One easy way to extract one parameter's value from your file is to use 'awk'.
# echo "par2=value2"|awk '/par2/ {split($0,a,/=/);print a[2]}'
..returns (prints) value2
# X=`echo "par2=value2"|awk '/par2/ {split($0,a,/=/);print a[2]}'`
Thus ${X} now contains 'value2', the value of 'par2'.
As for the shell construct 'set -x' --- this prints the shell commands as they are executed. This is useful in debugging. See the man pages for 'sh-psix' for more information.
Regards!
...JRF...
- Tags:
- awk
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-16-2006 12:13 AM
тАО01-16-2006 12:13 AM
Re: Manage parameter-file
I should generalize a bit; sorry. Given your parameter file is composed with "=" as the delimiter betweeen parameter and value, to find the value of parameter "X":
# X=par2;awk '{if ($1~X) {split($0,a,/=/);print a[2]}}' X=$X parmfile
...returns the value of 'par2'.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-16-2006 01:01 AM
тАО01-16-2006 01:01 AM
Re: Manage parameter-file
is there also a way to write a new value in the parameter-file without rewrite the whole parameter-file? also with awk.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-16-2006 01:52 AM
тАО01-16-2006 01:52 AM
Re: Manage parameter-file
Yes, you can update your file's parameters in place with perl:
# perl -i.old -ple 's/par2=.+\b/par2=newvalue/' parmsfile
...would make a backup copy "parmsfile.old" and update inplace the value of 'par2' changing it from whatever follows the "=" character to "newvalue".
Regards!
...JRF...
- Tags:
- Perl
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-16-2006 01:58 AM
тАО01-16-2006 01:58 AM
Re: Manage parameter-file
I suggest:
grep ^par1 parameter-file|cut -d"=" -f2|sed 's/^ *//g'
In this way you can have any number of spaces between = and the parameter value.
HTH,
Art
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-16-2006 02:06 AM
тАО01-16-2006 02:06 AM
Re: Manage parameter-file
Arturo's point about embedded spaces is easily managed:
# perl -i.old -ple 's/par2\s*=.+\b/par2=newvalue/' parmsfile
Regards!
...JRF...