Visit Our UNIX and Linux User Community

reading in properties file

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting reading in properties file
# 1  
Old 11-12-2010
reading in properties file

Am new to this scripting stuff so bear with me.
I got a script made now that reads in a properties file. The properties file is in the following format:
256= Bos, Sea, FRa
128= HEL
I want to be able to read in each line of the file and split out the letter fields by the numbered field. This way I can compare the lettered field to another value I have thus I will know which corrisponding number to set. Basically have a script now which starts up a worker and I need to know which number to set for each individual branch. Hope this makes sense. thanks
# 2  
Old 11-12-2010
Well, if you first write a display all, you can 'grep' that down to see on by either # or letters.
# 3  
Old 11-12-2010
# cat converttable
256= Bos, Sea, FRa
128= HEL

# cat file
Sea This HELis Testing Line in my document
ThisBos HELisTesting....
FRaSea Sea_FRa_HEL_Sea_Testing...

# ./justdoit file
Org File...
Sea This HELis Testing Line in my document
ThisBos HELisTesting....
FRaSea Sea_FRa_HEL_Sea_Testing...
Converted File...
256 This 128is Testing Line in my document
This256 128isTesting....
256256 256_256_128_256_Testing...

# ## justdoit ##
cp "$1" fileX
 for i in $(sed -e 's/^.*=\|,//g' converttable | sed  -e :a -e 'N;s/\n//' -e 'ta')
   convertto=$(sed -n "s/\(.*\)= .*\($i\).*/\1/p" converttable)
   sed -i "s/$i/$convertto/g" fileX
echo -e "Org File...\n====================="
more "$1"
echo ""
echo -e "Converted File...\n=================="
more fileX

Previous Thread | Next Thread
Test Your Knowledge in Computers #888
Difficulty: Easy
sed was developed from 1973 to 1974 by Bill Gates of Microsoft.
True or False?

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Reading properties from file and setting variable values

I want to read properties from a file and print evaluated values of each key. I am using AIX6.1. myfile.props protocol=http pageA=pageNameA siteAURL1=${protocol}:/${}/pagea/blabla?v1=32 siteAURL2=${protocol}:/${}/${pageA}/blabla?v1=32... (5 Replies)
Discussion started by: kchinnam
5 Replies

2. Shell Programming and Scripting

Installing a bin file by taking input from a properties file

I need to install a bin file in UNIX which requires user interaction for giving some information like user id , path, sid etc. All these information is stored in a properties file in the same location. So if i give ./file.bin -f will it install the file taking all the... (1 Reply)
Discussion started by: coolmohere
1 Replies

3. AIX

Reading .properties file on AIX and Windows

I have a FirstDoc application that integrates with SharePoint 2010. As per the FirstDoc install guide, I need to generate the sharepoint_authentication properties file and place it on the server and the 2 Windows boxes that contain other components of the app. The properties file I... (1 Reply)
Discussion started by: shoefiend
1 Replies

4. Shell Programming and Scripting

script to parse the properties file

Hi Friends, I have a requirement to parse a properties file having a key=value pairs. i need to count the number of key value pairs in the properties file and iterate through each key-value pair. I have written the script to read the number of lines from the property file, but cannot... (2 Replies)
Discussion started by: prashdeep
2 Replies

5. Shell Programming and Scripting

Reading the Properties File From Shell script

Hi, I am new to the shell script please I need help for following question. I have properties file name called "" I have No of key values in this properties. = xyz com.person.age = 55 com.person.address = hello I want read this properties but i... (1 Reply)
Discussion started by: venukjs
1 Replies

6. Shell Programming and Scripting

Problem with reading from a properties file

Hi, i have a properties file a.prop where entry is like PROCESS_IDX=0 Now in my shell schript i am doing like this. #!/bin/sh . a.prop .............. -....................... while read line do # tokenize the string by ",". var=(`echo $line | tr ',' ' '`) echo $PROCESS_IDX -->... (6 Replies)
Discussion started by: sailaja_80
6 Replies

7. Shell Programming and Scripting

Parsing a Complicated properties file

Hi All, I have a requirement to parse a file. Let me clear you all on the req. I have a job which contains multiple tasks and each task will have multiple attributes that will be in the below format. Each task will have some sequence number according to that sequence number tasks shld... (1 Reply)
Discussion started by: rajeshorpu
1 Replies

8. Linux

proble in running .properties file

# Timer for thread to sleep thread.sleep =15000 # To run the thread as daemon process = true # Copy command thread.cmd = C:\Program Files\Java\jdk1.5.0\bin\java CopyFile This is .properties file. CopyFile is name of program. is that ok. if i use cp command inplace of... (0 Replies)
Discussion started by: sari
0 Replies

9. UNIX for Dummies Questions & Answers

File properties

Hi , I do have a line in my code as follows: if ] ; then ... else ... fi What does the -z does ? Similarly there is -s in some other part of the code. I guess there are many options like this.. Can anybody please tell what all options are available and what do they mean ? (2 Replies)
Discussion started by: risshanth
2 Replies

10. HP-UX

Depot file properties

Hi How can we identify the informations like Author, meta data, dependency and other information from a depot file? (1 Reply)
Discussion started by: sethumadhavan
1 Replies

Featured Tech Videos