How to Assign an shell array to awk array?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to Assign an shell array to awk array?
# 8  
Old 09-19-2013
Yes, this is a query of Outlook I think text lines are joined up into a paragraph unless they start with 1 or more spaces try:

Code:
awk -v A="$(printf "%s\n" "${ARR[@]}")" '
BEGIN {
v=split(A,B,"\n");
while(i++<v) print " " B[i] } '

# 9  
Old 09-19-2013
Quote:
Originally Posted by Chubler_XL
Yes, this is a query of Outlook I think text lines are joined up into a paragraph unless they start with 1 or more spaces try:

Code:
awk -v A="$(printf "%s\n" "${ARR[@]}")" '
BEGIN {
v=split(A,B,"\n");
while(i++<v) print " " B[i] } '

I am getting same output, everything in single line.
# 10  
Old 09-19-2013
Outlook is infamous for imposing formatting, to the point <pre> tags or sending all text as email attachments isn't unheard of to make text line up/appear proper.
# 11  
Old 09-19-2013
I do remember a workaround I used for this in the past, try two spaces at the front of each line.

Code:
awk -v A="$(printf "%s\n" "${ARR[@]}")" '
BEGIN {
v=split(A,B,"\n");
while(i++<v) print "  " B[i] } '

It's also a good idea in outlook to select a nice non-proportional font for plain text messages.
This User Gave Thanks to Chubler_XL For This Post:
# 12  
Old 09-19-2013
Quote:
Originally Posted by Chubler_XL
I do remember a workaround I used for this in the past, try two spaces at the front of each line.

Code:
awk -v A="$(printf "%s\n" "${ARR[@]}")" '
BEGIN {
v=split(A,B,"\n");
while(i++<v) print "  " B[i] } '

It's also a good idea in outlook to select a nice non-proportional font for plain text messages.
This looks good works as expected, also i am curious is the same output or workaround possible with just printf statement and with out using awk ? what should i do to achieve it?

Thanks much
# 13  
Old 09-19-2013
how about printf " %s\n"
This User Gave Thanks to Corona688 For This Post:
# 14  
Old 09-20-2013
Quote:
Originally Posted by Chubler_XL
I do remember a workaround I used for this in the past, try two spaces at the front of each line.

Code:
awk -v A="$(printf "%s\n" "${ARR[@]}")" '
BEGIN {
v=split(A,B,"\n");
while(i++<v) print "  " B[i] } '

It's also a good idea in outlook to select a nice non-proportional font for plain text messages.
In the your code while(i++<v) does v represents a number or a string?

Thank you.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Assign Two Dimensional Array In Bash At Once

Hi, I have a 10*10 two dimensional array. How do I assign value to all it's 100 elements at once? I don't want to open two for loops and assign one by one. Thanks, Shuri (1 Reply)
Discussion started by: shurimano
1 Replies

2. Shell Programming and Scripting

awk assign output of array to specific field-number

With this script i want to print the output to a specific field-number . Can anybody help? awk 'NR=FNR{split(FILENAME,fn,"_");nr=$2;f = $1} END{for (i=1;i<=f;i++) print i,$fn=nr}' input_5.csv input_6.csvinput_5.csv 4 135 5 185 6 85 11 30input_6.csv 1 90 3 58 4 135 7 60 8 55 10... (1 Reply)
Discussion started by: sdf
1 Replies

3. Shell Programming and Scripting

Assign zero to strings that don't appear in block, store result in AWK array

Hi to all, I have this input: <group> <x "2">Group D</x> <x "3">Group B</x> <x "1">Group A</x> </group> <group> <x "1">Group E</x> <x "0">Group B</x> <x "1">Group C</x> </group> <group> ... (11 Replies)
Discussion started by: Ophiuchus
11 Replies

4. Shell Programming and Scripting

Assign value to array separated by #

Hi all , I have a string like para1#para2#para3 i want to assign para1 as first element para2 as second and so on i tried IFS=# set -A array para1#para2#para3 echo ${array} para1 para2 para3 i want echo ${array} para1 (2 Replies)
Discussion started by: max_hammer
2 Replies

5. Shell Programming and Scripting

assign value to array variable

Hi, I have a piece of code as follows: i=0 while read LINE do var = "$LINE" i=$((i+1)) echo "${var}" done < file I want to assign value to the array var. However, when i execute the script i get a error. Please can you help me know what i am missing. I ultimately want to... (2 Replies)
Discussion started by: sunrexstar
2 Replies

6. Shell Programming and Scripting

Cut text and assign them into array

file.txt : is delimiter: abc:def:ghi jkl:mno: pqr 123:456:789 if I do the cut command, and cut the first column, and echo it out I will get the output: abc jkl 123 How can I assign the column of text that I've cut into Array? e.g If I were to echo array array it will output as:... (9 Replies)
Discussion started by: andylbh
9 Replies

7. Shell Programming and Scripting

How to assign a variable to an array

I want to ask the user to enter an X amount of file names. I want to put those names into an array and then loop back through them to verify they are in the directory. 1st- How would I assign the value to an array and what is the correct syntax. 2nd- how would i reference that array after I... (3 Replies)
Discussion started by: tvb2727
3 Replies

8. Shell Programming and Scripting

retaining awk array in shell

Is there a way to retain the awk array in the shell. My requirement file a.txt A B Count 10 1 25 10 2 20 10 3 21 11 1 20 11 2 22 12 2 40 12 3 15 A and B are my variables and count... (6 Replies)
Discussion started by: jagpreetc
6 Replies

9. Shell Programming and Scripting

Accessing awk array from shell

Hi, i want awk to read a file and place it's content into two arrays. When trying to read these arrays with a "for a in ${source_path} "-Loop it gives the right result. But when trying to access directly (/bin/echo ${source_path}) it doesn't work. I read "all "the awk threads in this forum and... (6 Replies)
Discussion started by: bateman23
6 Replies

10. Shell Programming and Scripting

assign awk array with printf

I am trying to assign a awk array for further processing later in the script. I can't seem to figure it out. If someone could look at this and help me, I would very much appreciate it. Thanks in Advance. for ( x = 1 ; x <= Var ; x++ ) { if ( x in varr ) { ... (2 Replies)
Discussion started by: timj123
2 Replies
Login or Register to Ask a Question