output of an array


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting output of an array
# 1  
Old 03-21-2007
output of an array

Hi gurus,

I need to set up an array like this

set - A arr 'A', 'B'

The output of this array should be like this 'A','B'

Right now, I get the output like this 'A B'

Can anyone suggest me on how to achieve this.

thanks
# 2  
Old 03-22-2007
Hi,

You have to do something like this to acheive this...

typeset -a Arr
Arr[1]=\'A\'
Arr[2]=\'B\'
echo ${Arr[1]} ${Arr[2]}

Will give you the desired o/p.
# 3  
Old 03-22-2007
Works for me...
Code:
$ cat array
#! /usr/bin/ksh

set -A arr A B
echo first ${arr[0]}
echo second ${arr[1]}
exit 0

$ ./array
first A
second B
$

# 4  
Old 03-22-2007
thanks a lot for your help guys. i was able to get it either ways..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Formatting Array Output

Hello All, Q1) I have the below code but when the email was sent out all lines are merged and coming out as a single line though my printf statement has newline "\n", How do i avoid that? Q2) In my second IF statement when i introduced the backslash "\" for continuation of a line or command, i... (10 Replies)
Discussion started by: Ariean
10 Replies

2. Shell Programming and Scripting

Need to have output of AWK array in one line

I have this code echo $logfile | awk ' {arr++; next} END { for (i in arr) {print i} }' that gives me this output result1 result2 result3 I try to figure out how to get it like this result1 result2 result3 (4 Replies)
Discussion started by: Jotne
4 Replies

3. Shell Programming and Scripting

Output find to array

Hi I'm trying to write a shell script which finds all the .zip files in a given directory then lists them on the screen and prompts the user to select one by entering a number e.g. The available files are: 1. HaveANiceDay.zip 2. LinuxHelp.zip 3. Arrays.zip Please enter the... (4 Replies)
Discussion started by: zX TheRipper Xz
4 Replies

4. Shell Programming and Scripting

Store the output values in array

Hi, How to store the values in array from output result, EG: I have the result like this, ps, google, 1.txt, 1 sam, google, 2.txt, 2 These are the four values followed by comma in two sets. I need to store these values set by set. One set contains four values followed by comma. ... (2 Replies)
Discussion started by: KarthikPS
2 Replies

5. Shell Programming and Scripting

Filter output as an array element

I am filtering the value of Server status from a file and am storing it in a temp file which I compare later to exit with appropriate status. I am wondering if I can directly output the value of Server status as an array element and then compare the value of elements to get the right exit status ... (2 Replies)
Discussion started by: paslas
2 Replies

6. Shell Programming and Scripting

Output of shell in array

Hi, i have a file which reads, arun/manager/200000 pradeep/engineer/10000 karthik/teamlead/30000 ..... i want an output to show, name role salary ======================= arun manager 200000 pradeep engineer 10000 and so on.. i want to do... (9 Replies)
Discussion started by: pradebban
9 Replies

7. Filesystems, Disks and Memory

iostat output vs TPC output (array layer)

Hi Guys, I've been having some arguments with my colleagues about one thing. Always my thought was that as as far as disk performance is concern by looking at the output of the iostat command (AIX) you would be able to identify if you have a hot disk and then by moving some files out that disk... (3 Replies)
Discussion started by: arizah
3 Replies

8. Shell Programming and Scripting

System Output in to an Array or variable

hey guys in only new to scripting as such, but i have a problem. i want to take the output of a search i do in the command line to then be in a variable but only a certain part of the output. this this what im doing: -bash-2.05b$ ldapsearch -x '(dn:=dc)' dc|grep dc= # base... (1 Reply)
Discussion started by: jmorey
1 Replies

9. Shell Programming and Scripting

Put output into an array

I'm trying to take the output of an environment that has multiple strings ex. # echo $SSH_CLIENT 192.168.1.1 57039 22 I need that IP... so I can set it to another environment. Thank you (3 Replies)
Discussion started by: adelsin
3 Replies

10. Shell Programming and Scripting

move output of awk to array

Hi experts, I have a the following awk command, awk '{print $1}' /users/jon/list4.txt. The output is 123 787 888 ... ... I want to move the output to array using shell programming. My shell is tcsh. Is it possible to move to array using shell porg? I know its possible in... (14 Replies)
Discussion started by: amitrajvarma
14 Replies
Login or Register to Ask a Question