Sponsored Content
Top Forums Shell Programming and Scripting reading and updating property file Post 302583066 by Corona688 on Monday 19th of December 2011 12:56:17 PM
Old 12-19-2011
Quote:
Originally Posted by rakeshranjanscs
Finally I managed to read the contents of property file using statement like

cut -d"|" -f1 $PROPERTIES_FILE | tr '\n' ' ' <-- Reading first column
Not an efficient or direct way to do so, try a loop and the read statement. You can use the special IFS variable to control what it splits fields on. A loop would even be able to handle multiple lines.

Code:
while IFS="|" read COL1 COL2 COL3 COL4
do
        ...
done < inputfile

To update, you could do something like

Code:
while IFS="|" read COL1 COL2 COL3 COL4
do
        # Alter column 4 on every line
        COL4="newvalue"
        echo "${COL1}|${COL2}|${COL3}|${COL4}"
done < inputfile > outputfile
# Overwrite input with output
cat outputfile > inputfile
# delete outputfile
rm outputfile

---------- Post updated at 11:56 AM ---------- Previous update was at 11:51 AM ----------

Assuming the file only contains a single line, you can read and update it without the loop and without the temporary file:

Code:
IFS="|" read COL1 COL2 COL3 COL4 < inputfile
COL4="newvalue"
echo "${COL1}|${COL2}|${COL3}|${COL4}" > inputfile

 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

awk updating one file with another, comparing, updating

Hello, I read and search through this wonderful forum and tried different approaches but it seems I lack some knowledge and neurones ^^ Here is what I'm trying to achieve : file1: test filea 3495; test fileb 4578; test filec 7689; test filey 9978; test filez 12300; file2: test filea... (11 Replies)
Discussion started by: mecano
11 Replies

2. Shell Programming and Scripting

perl use property file for variables

if I have a file that contains variables. How do I assign them in a script. file p=c e=g Thanks (3 Replies)
Discussion started by: 3junior
3 Replies

3. Shell Programming and Scripting

Help with reading file with values and updating another file

Hi I need some help with a task, i am an absolute newbie to any form of shell scripting and request guidance. Task: 1. Read a config file in form of name value pair ex host=www.test.com port=8080 binding="dynamic" or "other" or "something else" key1=value1 key2=value2 key3=value4... (4 Replies)
Discussion started by: mk7074
4 Replies

4. Shell Programming and Scripting

change word in a property file

Hi, I have a property file called "inspector.properties". In this property file stands the following: inspect=ON Now I want to have a shell script that when you run it, changes the ON in OFF in this property file. Is this possible with sed? Can anybody help me with this? Tnx very much. (5 Replies)
Discussion started by: thebladerunner
5 Replies

5. Shell Programming and Scripting

Reading from one file and updating other file with constant entries

Hi All, Thaks for the help in my last thread. I have one more question. I have two files with ldap entries in it. One file contains all the user LDAP parameter entries (26 MB) and other file contains only the user id's that have to be inactivated. Unix script has to read from the file that has... (8 Replies)
Discussion started by: Samingla
8 Replies

6. Shell Programming and Scripting

Report a missing property and property value mis match script.

Hi All, I have 2 properties files - one is a master templete and other one is a node specific properties file, I need to comapre these 2 properties files and make sure the node Specific properties file contains all the properties in the master temple properties file else report the missing... (5 Replies)
Discussion started by: jayka
5 Replies

7. Shell Programming and Scripting

Reading a property file through shell script???

Hi! i need a script that can read a property file. i.e., A script to read a "property" from property file. Read the property value and based on value of property, decide whether to start the some dataload activity or not. Its urngent. Can anyone help me out???:( (7 Replies)
Discussion started by: sukhdip
7 Replies

8. Shell Programming and Scripting

Property file processing in unix

Hi genius, Following is the problem. We have one templete file(input file) where some variables will be used Example: word1 word2 &{word3} word4 ${word5} word6 And also we have one property file where we define these variables Example: word3= something Word5= something Need to read... (5 Replies)
Discussion started by: gjarms
5 Replies

9. UNIX for Beginners Questions & Answers

Parse property from json file

Hello All, Greetings.. I have a json file that I need to pase its URLs and other values. The match should start with "notifications" and output URLs and settings values. I tried with python or awk but hardly could get URLs only. Or whole URLs from full json file. Could not match... (2 Replies)
Discussion started by: 7adi
2 Replies
XmDeactivateProtocol(3X)												  XmDeactivateProtocol(3X)

NAME
XmDeactivateProtocol - A VendorShell function that deactivates a protocol without removing it SYNOPSIS
#include <Xm/Xm.h> #include <Xm/Protocols.h> void XmDeactivateProtocol (shell, property, protocol) Widget shell; Atom property; Atom protocol; void XmDeactivateWMProtocol (shell, protocol) Widget shell; Atom protocol; DESCRIPTION
XmDeactivateProtocol deactivates a protocol without removing it. It updates the handlers and the property, if the shell is realized. It is sometimes useful to allow a protocol's state information (callback lists, etc.) to persist, even though the client may choose to tempo- rarily resign from the interaction. The main use of this capability is to gray/ungray f.send_msg entries in the Mwm system menu. This is supported by allowing a protocol to be in one of two states: active or inactive. If the protocol is active and the shell is realized, the property contains the protocol Atom. If the protocol is inactive, the Atom is not present in the property. XmDeactivateWMProtocol is a convenience interface. It calls XmDeactivateProtocol with the property value set to the atom returned by interning WM_PROTOCOLS. Specifies the widget with which the protocol property is associated Specifies the protocol property Specifies the protocol atom (or an int type cast to Atom) For a complete definition of VendorShell and its associated resources, see VendorShell(3X). SEE ALSO
mwm(1X), VendorShell(3X), XmDeactivateWMProtocol(3X), XmInternAtom(3X) XmDeactivateProtocol(3X)
All times are GMT -4. The time now is 01:43 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy