Sponsored Content
Top Forums UNIX for Beginners Questions & Answers Replacing settings in config files. Post 303008138 by MadeInGermany on Monday 27th of November 2017 05:03:40 PM
Old 11-27-2017
With shell builtins (no external command awk, sed, perl)
here is a standard procedure
Code:
fn="file.conf"
# split on =, change the certain value, write to .new file:
while IFS="=" read key val
do
  case $key in
  "Another Setting") val=27;;
  esac
  printf "%s\n" "$key=$val"
done < $fn > $fn.new
# If successful
if [ $? -eq 0 ]
then
  # copy back to the original file; if successful delete the .new file
  cp $fn.new $fn &&
  rm $fn.new
fi

 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

new LAN, where are the config files?

We just moved to a new office so few things changed on our LAN. I am on Solaris and trying to find the files that hold the configuration for connecting to the servers. I changed the IP addresses to reflect the new addresses but still I get this error: “unknown sendmail : unable to qualify my own... (3 Replies)
Discussion started by: softarch
3 Replies

2. UNIX for Dummies Questions & Answers

Apache Config Files

Currently our Apache log files are huge, I want to put say a month's time limit on this, then when it hits the end of the month I would like it to start over writing. Does anyone know where the config file is for this and what its called? I also want to do exactly the same on wtmp config (who... (1 Reply)
Discussion started by: Webwitch
1 Replies

3. HP-UX

Config Files

Does anyone have a list of key config files and the respective paths for HP-UX? Or does anyone know where I can get a list similar to this? Thanks, TOdd (0 Replies)
Discussion started by: toddjameslane
0 Replies

4. OS X (Apple)

Terminal.app keeps creating copies of my settings files

Under Leopard, I like to conveniently open Terminal windows onto remote systems. I've created several settings files in Terminal, one for each remote system that I want to access. To open window, I right-click on the Terminal icon in the Dock, expand the "New Window" menu item, and select the... (0 Replies)
Discussion started by: siemsen
0 Replies

5. Shell Programming and Scripting

parsing config file to create new config files

Hi, I want to use a config file as the base file and parse over the values of country and city parameters in the config file and generate separate config files as explained below. I will be using the config file as mentioned below: (config.txt) country:a,b city:1,2 type:b1... (1 Reply)
Discussion started by: clazzic
1 Replies

6. Shell Programming and Scripting

Shell script that will compare two config files and produce 2 outputs 1)actual config file 2)report

Hi I am new to shell scripting. There is a requirement to write a shell script to meet follwing needs.Prompt reply shall be highly appreciated. script that will compare two config files and produce 2 outputs - actual config file and a report indicating changes made. OS :Susi linux ver 10.3. ... (4 Replies)
Discussion started by: muraliinfy04
4 Replies

7. Shell Programming and Scripting

using perl config files

Hi, I have 2 perl SubRoutines (sub 1 and sub 2). I created two perl modules for these (Sub1.pm and Sub2.pm). How can I include these in a config file (say Config.cfg) and call the config file in my main script Rename.pl to use the 2 subroutines? Right now here are the content of Config.cfg... (1 Reply)
Discussion started by: CCFP
1 Replies

8. Shell Programming and Scripting

What's the best way to read config files?

(copied directly from my other thread about something else) At the moment, I just use... cat config_file|grep var_name|cut -d'=' -f2 ... which is fine for what I've been doing, but I'm not sure what to do when there are a variable number of entries and I want it go through them like a... (7 Replies)
Discussion started by: ninjaaron
7 Replies

9. Shell Programming and Scripting

Search a particular config in many files

Hi, Having trouble in our network we would like to implement a second "ip-helper" (to have DHCP redondancy) to do so we have to take all the network elements config (switches and routers) , finds where the particular config is and add a second line. To do so we need to have a list where this... (1 Reply)
Discussion started by: Philalapatte
1 Replies

10. Windows & DOS: Issues & Discussions

(VS 2008) New build config looking files from other folder build config

Hi Team, My new build configuration always looking for the files from the build where i copied from. please help me to resolve this. I am using Visual studio 2008.It has Qt 4.8. plugins,qml,C++ development I created new debug_new build configuration with additional preprocessor from the... (1 Reply)
Discussion started by: SA_Palani
1 Replies
PROP_DICTIONARY_UTIL(3) 				   BSD Library Functions Manual 				   PROP_DICTIONARY_UTIL(3)

NAME
prop_dictionary_util, prop_dictionary_get_dict, prop_dictionary_get_bool, prop_dictionary_set_bool, prop_dictionary_get_int8, prop_dictionary_get_uint8, prop_dictionary_set_int8, prop_dictionary_set_uint8, prop_dictionary_get_int16, prop_dictionary_get_uint16, prop_dictionary_set_int16, prop_dictionary_set_uint16, prop_dictionary_get_int32, prop_dictionary_get_uint32, prop_dictionary_set_int32, prop_dictionary_set_uint32, prop_dictionary_get_int64, prop_dictionary_get_uint64, prop_dictionary_set_int64, prop_dictionary_set_uint64, prop_dictionary_get_cstring, prop_dictionary_set_cstring, prop_dictionary_get_cstring_nocopy, prop_dictionary_set_cstring_nocopy, prop_dictionary_set_and_rel -- dictionary property collection object utility functions LIBRARY
Property Container Object Library (libprop, -lprop) SYNOPSIS
#include <prop/proplib.h> bool prop_dictionary_get_dict(prop_dictionary_t dict, const char *key, prop_dictionary_t *dictp); bool prop_dictionary_get_bool(prop_dictionary_t dict, const char *key, bool *valp); bool prop_dictionary_set_bool(prop_dictionary_t dict, const char *key, bool val); bool prop_dictionary_get_int8(prop_dictionary_t dict, const char *key, int8_t *valp); bool prop_dictionary_get_uint8(prop_dictionary_t dict, const char *key, uint8_t *valp); bool prop_dictionary_set_int8(prop_dictionary_t dict, const char *key, int8_t val); bool prop_dictionary_set_uint8(prop_dictionary_t dict, const char *key, uint8_t val); bool prop_dictionary_get_int16(prop_dictionary_t dict, const char *key, int16_t *valp); bool prop_dictionary_get_uint16(prop_dictionary_t dict, const char *key, uint16_t *valp); bool prop_dictionary_set_int16(prop_dictionary_t dict, const char *key, int16_t val); bool prop_dictionary_set_uint16(prop_dictionary_t dict, const char *key, uint16_t val); bool prop_dictionary_get_int32(prop_dictionary_t dict, const char *key, int32_t *valp); bool prop_dictionary_get_uint32(prop_dictionary_t dict, const char *key, uint32_t *valp); bool prop_dictionary_set_int32(prop_dictionary_t dict, const char *key, int32_t val); bool prop_dictionary_set_uint32(prop_dictionary_t dict, const char *key, uint32_t val); bool prop_dictionary_get_int64(prop_dictionary_t dict, const char *key, int64_t *valp); bool prop_dictionary_get_uint64(prop_dictionary_t dict, const char *key, uint64_t *valp); bool prop_dictionary_set_int64(prop_dictionary_t dict, const char *key, int64_t val); bool prop_dictionary_set_uint64(prop_dictionary_t dict, const char *key, uint64_t val); bool prop_dictionary_get_cstring(prop_dictionary_t dict, const char *key, char **strp); bool prop_dictionary_set_cstring(prop_dictionary_t dict, const char *key, const char *str); bool prop_dictionary_get_cstring_nocopy(prop_dictionary_t dict, const char *key, const char **strp); bool prop_dictionary_set_cstring_nocopy(prop_dictionary_t dict, const char *key, const char *strp); bool prop_dictionary_set_and_rel(prop_dictionary_t dict, const char *key, prop_object_t obj); DESCRIPTION
The prop_dictionary_util family of functions are provided to make getting and setting values in dictionaries more convenient in some applica- tions. The getters check the type of the returned object and, in some cases, also ensure that the returned value is within the range implied by the getter's value type. The setters handle object creation and release for the caller. The prop_dictionary_get_cstring() function returns dynamically allocated memory. See prop_string(3) for more information. The prop_dictionary_get_cstring_nocopy() and prop_dictionary_set_cstring_nocopy() functions do not copy the string that is set or returned. See prop_string(3) for more information. The prop_dictionary_set_and_rel() function adds the object to the dictionary and releases it. The object is also released on failure. RETURN VALUES
The prop_dictionary_util getter functions return true if the object exists in the dictionary and the value is in-range, or false otherwise. The prop_dictionary_util setter functions return true if creating the object and storing it in the dictionary is successful, or false other- wise. SEE ALSO
prop_bool(3), prop_dictionary(3), prop_number(3), proplib(3) HISTORY
The proplib property container object library first appeared in NetBSD 4.0. BSD
August 7, 2011 BSD
All times are GMT -4. The time now is 02:51 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy