string manipulation in unix


 
Thread Tools Search this Thread
Operating Systems Linux string manipulation in unix
# 1  
Old 05-07-2008
string manipulation in unix

Hi,
I have a question . I have script which gets info from db2 engine.
The script is

cat sample_substitute.sh
CNTR_NM=`db2 -x "select CONTAINER_NAME ,usable_pages from table( SNAPSHOT_CONTAINER('TST103',-1)) as SNAPSHOT_CONTAINER, syscat.tablespaces where
tablespace_name = tbspace and tbspacetype = 'D' and tbspace='TSOPS06'" `
echo ${CNTR_NM}

The output is like this

/dmpath/dmtiadm1/db2fs1p00/tsops06 2128

But I am trying to get the output like this

'/dmpath/dmtiadm1/db2fs1p00/tsops06' 2128

i.e. the string inside the single quote.

Thanks again in advance !
# 2  
Old 05-07-2008
Maybe something like this:

Code:
echo ${CNTR_NM} | awk -v a="'" '{print a$1a, $2}'


Output:

Quote:
'/dmpath/dmtiadm1/db2fs1p00/tsops06' 2128
# 3  
Old 05-07-2008
try this

Code:
db2 -x "select CONTAINER_NAME ,usable_pages from table( SNAPSHOT_CONTAINER('TST103',-1)) as SNAPSHOT_CONTAINER, syscat.tablespaces where 
tablespace_name = tbspace and tbspacetype = 'D' and tbspace='TSOPS06'" | read container upages

echo "'${container}' ${upages}"

# 4  
Old 05-07-2008
Thanks a lot Rubin . It solved the problem !
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

String Manipulation

I'm making a little game in Perl, and I am trying to remove the first instance of a character in an arbitrary string. For example, if the string is "cupcakes"and the user enters another string that contains letters from "cupcake" e.g: "sake"the original string will now look like this (below)... (3 Replies)
Discussion started by: whyte_rhyno
3 Replies

2. Shell Programming and Scripting

String manipulation

Hi , I am getting a string like aaa,bbb,sdsdad,sdfsdf,sdfsdfdsf,rtyrtyr,45654654,ddfdfdfgdfg,dfgdfgdg........... Now what I need is to format it. So after each nth comma I need one newline. So the above will look like when n=3 aaa,bbb,sdsdad, sdfsdf,sdfsdfdsf,rtyrtyr,... (4 Replies)
Discussion started by: Anupam_Halder
4 Replies

3. Shell Programming and Scripting

Deleting part of a string : string manipulation

i have something like this... echo "teCertificateId" | awk -F'Id' '{ print $1 }' | awk -F'te' '{ print $2 }' Certifica the awk should remove 'te' only if it is present at the start of the string.. anywhere else it should ignore it. expected output is Certificate (7 Replies)
Discussion started by: vivek d r
7 Replies

4. Shell Programming and Scripting

string manipulation

hi all, i am new to shell scripting and need help. i have a string that stores the month in Jan/Feb/Mar format. i need to convert it to number like 01 for jan, 12 for dec etc. i am using the following sed command, echo "Enter a Month eg. Jan/Feb : " read MONTHEND ... (9 Replies)
Discussion started by: anupom2000
9 Replies

5. UNIX for Dummies Questions & Answers

Help with String manipulation

Dear All, I have a question. I have files with the following pattern.>S8_SK1.chr01 NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNCAGCATGCAATAAGGTGACATAGATATACCCACACACCACACCCTAACACTAACCCTAATCTAACCCTGGCCAACCTGTTT... (13 Replies)
Discussion started by: pawannoel
13 Replies

6. Homework & Coursework Questions

String Manipulation

Write a shell program to display the position of the right - most character in a given input string. Example : Input : RAHUL Output : L is in the 5th position also tell me how to count length of string and how to find the position of specific character in left most side. Homework... (0 Replies)
Discussion started by: shashwat2691
0 Replies

7. Shell Programming and Scripting

string manipulation

if I have two string variable, how do I add one to anther. like a= "a" b="b" c=$a+$b but that doesn't work. Is there anyway to solve it.http://www.qtl.co.il/img/copy.pnghttp://www.google.com/favicon.icohttp://www.babylon.com/favicon.icohttp://www.morfix.com/favicon.ico (2 Replies)
Discussion started by: programAngel
2 Replies

8. UNIX for Dummies Questions & Answers

String manipulation in Linux & Unix (Solaris)

Guy I have this below report and I need someone help me formatting it SID File Name Started Finished Backup ABC XYZ.log 10Sep09-012857\n 10Sep09-020748 Successful I need Started & Finished columns to be formatted as ... (1 Reply)
Discussion started by: anjum.suri
1 Replies

9. Shell Programming and Scripting

string manipulation

i have a file that contains a pattern like this: ajay 1234 newyork available kumar 2345 denver singh 2345 newyork ajay 3456 denver kumar 3456 newyork singh 3456 delhi available ajay 4567 miami kumar 4567 miami singh 4567 delhi i want to search for each line... (5 Replies)
Discussion started by: ajay41aj
5 Replies

10. Shell Programming and Scripting

string manipulation

Hi, I have searched this long and hard and don't seem to see another post on this issue. I have two strings each with the same characters but in a different order. String1=”word” String2=”dwor” I want to test them to show their similarity. Unfortunately I can't do a sort so that they will... (9 Replies)
Discussion started by: Cactus Jack
9 Replies
Login or Register to Ask a Question