Parse or cut concat variables to individual values


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Parse or cut concat variables to individual values
# 1  
Old 11-20-2010
Parse or cut concat variables to individual values

Hello

I need to pass some environment parameters to a datastage job and am getting an error when trying to send the complete concatinated variable. I have decided to parse out just the values and send as parameters but am struggling to find the best way to do this (actually I am not very experienced in the unix scripting syntax)

I need to parse/cut variables that look similar to the following:
Code:
MMDomain="-domain domainname:0000"
MMServer="-server servername:0000"
MMUser="-user username -password password"

I would like to turn these into parameters that I can pass to the datastage job and that look like the following:
Code:
PDomain=domainname:0000
PServer=servername:0000
PUser=username
Ppassword=password

I would really appreciate any help I could get on this as so far, I have had little success. Thanks you!

Last edited by Scott; 11-21-2010 at 07:16 AM.. Reason: Code tags
# 2  
Old 11-20-2010
one way:
Code:
echo "$MMDomain" | read dummy PDomain
echo "$MMServer" | read dummy PServer
echo "$MMUser"   | read dummy Pusername dummy2 Ppassword

# 3  
Old 11-20-2010
That will only work in ksh, any other shell will put the read in a subshell and hence not read the vars. Try echoing to a temp file and reading back from there.
# 4  
Old 11-20-2010
Thanks Jim.

I don't really understand it but it worked PERFECTLY!!! Smilie
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Cut two individual position and summ

Hi All, I am having a huge file file. I need to cut the below column and do the below calculation I did the below command and able to do on full databased no on the individual based any help on doing each row by row cut -c 52-56 myfile | awk '{total = total + $1}END{print total}'... (7 Replies)
Discussion started by: arunkumar_mca
7 Replies

2. Shell Programming and Scripting

Comma separated values to individual lines

My OS : RHEL 6.7 I have a text file with comma separated values like below $ cat testString.txt 'JOHN' , 'KEITH' , 'NEWMAN' , 'URSULA' , 'ARIANNA' , 'CHENG', . . . . I want these values to appear like below 'JOHN' , 'KEITH' , 'NEWMAN' , 'URSULA' , 'ARIANNA' , 'CHENG', .... (4 Replies)
Discussion started by: kraljic
4 Replies

3. Shell Programming and Scripting

Read record from the text file contain multiple separated values & assign those values to variables

I have a file containing multiple values, some of them are pipe separated which are to be read as separate values and some of them are single value all are these need to store in variables. I need to read this file which is an input to my script Config.txt file name, first path, second... (7 Replies)
Discussion started by: ketanraut
7 Replies

4. Shell Programming and Scripting

concat 2 variables with newline

Hi All, I'm a newbie here, i'm having proble concatinating my 2 variables. i tried na \n but it doesn't work. ex. var 1="YES,AGREE" var 2="NO,DISAGREE" expected output is: YES,AGREE NO,DISAGREE i tried this var 3 ="${var 1} \n ${var 2}" it outputs me YES,AGREE\nNO,DISAGREE... (2 Replies)
Discussion started by: nikki1200
2 Replies

5. Shell Programming and Scripting

Need to parse lines in a file into two words and assign the values to two variables

For example, I have a file with below lines containing VOB tags and VOB paths. * /vobs/fts/FTSUSM20_VOB /ccvobsslx01/projects/vobs/eml/FTSUSM20_VOB * /vobs/fts/FTS20_VOB /ccvobsslx01/projects/vobs/eml/FTS20_VOB * /vobs/pmv/PMS_VOB /ccvobsslx01/projects/vobs/cpm/_/PMS_VOB *... (4 Replies)
Discussion started by: senthilkc
4 Replies

6. Shell Programming and Scripting

Help with cut and parse the line

I have log file which contains 1000s of lines something like this. INFO |2010-08-29 14:23:37,078|SERIAL_ID=1283109816352|ST=2010-08-2914:23:36|DP_DEVICE=11.22.33.44:4420|TYPE=TransactionLo g|LOG_LEVEL=6|CLASS=Superior... (7 Replies)
Discussion started by: baraghun
7 Replies

7. Shell Programming and Scripting

Parse config file and store the values in variables

Hi, I have a config file that has blank, commented lines. I need to escape commented lines, blank lines, parse the remaining lines and store them in variables or array. the config file contains the following lines. # config file # Define Oracle User ORA_USER=abcde ORA_PASS=xyzabc... (8 Replies)
Discussion started by: Lakshmi Chowdam
8 Replies

8. Shell Programming and Scripting

Turning CSV files into individual Variables

I want to be able to convert the following data from a CSV into individual variables from the columns 2 4 and 8 I can use awk to grab the columns using var1=`cat text.csv | awk "," '{print $2}'` but how do I create separate variables for each line. 595358 ,ECON1010 ,THU ,08:00 - 10:00 ,11 Mar... (6 Replies)
Discussion started by: domsmith
6 Replies

9. Shell Programming and Scripting

list file content as individual variables

Hello, I've created a couple of files within a list using the command "ls -ltr | tail -2 > list" These files are the newest files placed within a directory. From the "list" file, I need to place the filenames as a variable. In which the newest file will be called "new_ctrl" the older file... (4 Replies)
Discussion started by: petersf
4 Replies

10. Shell Programming and Scripting

How to parse a string into variables

I'm working in korn shell and have a variable which contains a string like: aa_yyyymmdd_bbb_ccc_ddd.abc. I want to treat the _ and . as delimiters and parse the string so I end up with 6 values in variables that I can manipulate. My original plan was to use var1=`echo $sting1 | cut -c1-c2` but... (9 Replies)
Discussion started by: aquimby
9 Replies
Login or Register to Ask a Question