Concatenating string with numbers


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Concatenating string with numbers
# 1  
Old 11-25-2009
Concatenating string with numbers

Hi,
I want to display the string value with number value. I dont know how to display. Can anyone help me.
This is my code
Code:
export A=${file_name}
echo $a $b $sum | awk '{ printf "%011.f,%014.f,%014.f\n", $1,$2,$3}' >> ${MRR_OUTPUT}

the out put shold be

${A}, $a, $b

filename, 00000000011, 00000123456754, 00000123456754

Thanks in advance,
Raj.

Last edited by jim mcnamara; 11-25-2009 at 10:39 AM.. Reason: add code tags
# 2  
Old 11-25-2009
You left $A out of your format:

Code:
| awk '{ printf "%s %011.f,%014.f,%014.f\n", $A, $1,$2,$3}'


Last edited by TonyLawrence; 11-25-2009 at 10:38 AM.. Reason: forgot to quote code
# 3  
Old 11-25-2009
awk printf requires ( and ) around the arguments. You can use the printf command line utility which does not need ( and )
Code:
printf "%s, %011.f, %014.f, %014.f\n" $A $a $b $sum >> ${MRR_OUTPUT}

GNU awk printf does not require ( and ).

Last edited by jim mcnamara; 11-25-2009 at 10:48 AM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Concatenating(??) shell variable with string

Dear Users, I am writing a for loop in shell (BASH), and am struggling with a very specific detail: SU_DATA=/home/........./su/ for(blah blah blah) { a=1001 b=1002 suop2 $SU_DATA/$a_clean.su $SU_DATA/$b_clean.su op=sum > W1.su } Here, it looks like the variables are... (1 Reply)
Discussion started by: martm
1 Replies

2. Shell Programming and Scripting

Adding numbers in a string

I am writing a bash script on ubuntu11.10 I have some string having numbers and letter and want to add all the numbers together For example 1s2d23f I want to perform 1 + 2 + 23 and store it in a variable (3 Replies)
Discussion started by: kristinu
3 Replies

3. Shell Programming and Scripting

de concatenating a string

I have a variable var=string1:string2:string3 I want to get the string de-concatenated and put it as var1=string1 var2=string2 var3=string3 Thanks in advance. ---------- Post updated at 02:18 PM ---------- Previous update was at 01:45 PM ---------- I got the solution as below:... (2 Replies)
Discussion started by: Deepak62828r
2 Replies

4. Shell Programming and Scripting

Concatenating File and String for Sendmail

I want o add a variable in addition to a file which will be send with sendmail. I have problems to find the correct syntax for concatenating this variable called $MyVariable. sendmail mai@domain.com </tmp/errormessage.txt $MyVariable] Thanks for your help! (2 Replies)
Discussion started by: high5
2 Replies

5. Shell Programming and Scripting

Concatenating and appending string based on specific pattern match

Input #GEO-1-type-1-fwd-Initial 890 1519 OPKHIJEFVTEFVHIJEFVOPKHIJTOPKEFVHIJTEFVOPKOPKHIJHIJHIJTTOPKHIJHIJEFVEFVOPKHIJOPKHIJOPKEFVEFVOPKHIJHIJEFVHIJHIJEFVTHIJOPKOPKTEFVEFVEFVOPKHIJOPKOPKHIJTTEFVEFVTEFV #GEO-1-type-2-fwd-Terminal 1572 2030... (7 Replies)
Discussion started by: patrick87
7 Replies

6. UNIX for Dummies Questions & Answers

Breaking a string into four different numbers

I'm having trouble breaking a string into four different numbers. What I'm starting out with is foo='1218141 1441 1664 122222' and what I want to have is a=1218141 b=1441 c=1664 d=122222 I'm tried using some pattern matching to break the string up into these four different... (7 Replies)
Discussion started by: Azumandious
7 Replies

7. Programming

Concatenating array of strings into one string separated by spaces

Hi, Well as the title says, I have an array of strings (delimited by null). The length of the array is variable and length of each string is variable as well. What I need is one huge string with the original strings in the array separated by spaces. For example is an array is such that array... (12 Replies)
Discussion started by: newhere
12 Replies

8. Shell Programming and Scripting

How do i get numbers from a string?

Hi... I'm new here and i have a Q... How do i get only the number from a string? like from "rlvol11" i want to get 11 or from "lvol4" i want to get 4 what commands should i use at my script? thanx 4 the help! Eliraz. (13 Replies)
Discussion started by: eliraza6
13 Replies

9. UNIX for Dummies Questions & Answers

concatenating string and variable

how to concatenate a string and variable like a=rahul and i want to put it into another variable 'b' as "rahul_prasath" i dont want to use another variable for "_prasath" how to do it? (1 Reply)
Discussion started by: rolex.mp
1 Replies

10. Shell Programming and Scripting

concatenating static string to records in data file

I just need to add a static ID to each output record so the users will be able to tell which group records in combined flatfiles come from I have the static ID in a bourne variable. I tried awk '{print "${GroupID}" $0}' infile > outfile But I ended up with the string ${GroupID} instead of... (5 Replies)
Discussion started by: gillbates
5 Replies
Login or Register to Ask a Question