Put output into an array


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Put output into an array
# 1  
Old 03-10-2010
Put output into an array

I'm trying to take the output of an environment that has multiple strings

ex.
Code:
# echo $SSH_CLIENT
192.168.1.1 57039 22

I need that IP... so I can set it to another environment.

Thank you
# 2  
Old 03-10-2010
Code:
IP=${SSH_CLIENT%% *}

# 3  
Old 03-10-2010
Thank you Franklin52.

Is there any way I could have a break down on why that works so I may better understand it?
# 4  
Old 03-10-2010
Quote:
Originally Posted by adelsin
Thank you Franklin52.

Is there any way I could have a break down on why that works so I may better understand it?
Have a read of this:

Learning the Korn Shell, 2nd Edition: Chapter 4: Basic Shell Programming

Regards
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Read file and get the data then put it in array

Hi, I have a file called "readfile" it contains below parameters #cat readfile word=/abc=225,/abc/cba=150 three=12 four=45 five=/xyz/yza likewise multiple line. From the above file, I have to read "word" output should be like, /abc /abc/cba these values need to be put in... (3 Replies)
Discussion started by: munna_dude
3 Replies

2. Shell Programming and Scripting

Perl : Large amount of data put into an array

This basic code works. I have a very long list, almost 10000 lines that I am building into the array. Each line has either 2 or 3 fields as shown in the code snippit. The array elements are static (for a few reasons that out of scope of this question) the list has to be "built in". It... (5 Replies)
Discussion started by: sumguy
5 Replies

3. Shell Programming and Scripting

How do I put data piped to my script into an array for repeated processing

Hi folks, Sorry for something I'm sure was answered already, I just could not find it in a search of the forums. I am trying to build a script that eats a config file as: cat file.cnf | ConProcess.shWhat I want to do inside the script is: !#/usr/bin/bash # captured piped cat into an... (6 Replies)
Discussion started by: Marc G
6 Replies

4. Shell Programming and Scripting

Get tokens from line and put them into an array

I have a line like: IDNO H1 H2 H3 HT Q1 Q2 Q3 Q4 Q5 M1 M2 EXAM I would like to be able to access these tokens in such a way: echo $myline #displays IDNO Is this possible to do in a shell script? (3 Replies)
Discussion started by: afulldevnull
3 Replies

5. Shell Programming and Scripting

Extract specific text from variable and put it into array

Dear community, I have to do something too hard for me :rolleyes:. I hope you can help me. This is an output coming from Oracle query, stored in a file called query.out, there are many rows, but I read them, one by one, using while/read/done. Assuming each row is contained into $line variable... (8 Replies)
Discussion started by: Lord Spectre
8 Replies

6. Programming

put an 2D array in shared memory

Hi, I want to make 2 simple programs communicate each other with shared memory. The programs will share an 2D array. In the first program (intarr.c) i create an x array which is: 1 2 3 4 5 6 7 8 9 10 11 12 and i call the second program (intarr2.c) with execvp(); giving it the segment id as an... (2 Replies)
Discussion started by: giampoul
2 Replies

7. Shell Programming and Scripting

How to put db2 query result into an array in shell script?

Hello, Can someone please advise me how to put the db2 query reult into an array? For example, the query reults are: string A string B string C Then how do I put them into array=string A array=string B ... (2 Replies)
Discussion started by: hanul
2 Replies

8. Programming

how to put element of an array to first position.

hi, I have a array like my $array = ( "apple","ball","cat","dog","elephant"); how to push some element in the array to the first position. for example my final array should be elephant apple ball cat dog (5 Replies)
Discussion started by: vprasads
5 Replies

9. Shell Programming and Scripting

perl, put one array into many array when field is equal to sth

Hi Everyone, #!/usr/bin/perl use strict; use warnings; my @test=("a;b;qqq;c;d","a;b;ggg;c;d","a;b;qqq;c;d"); would like to split the @test array into two array: @test1=(("a;b;qqq;c;d","a;b;qqq;c;d"); and @test2=("a;b;ggg;c;d"); means search for 3rd filed. Thanks find the... (0 Replies)
Discussion started by: jimmy_y
0 Replies

10. Shell Programming and Scripting

Put lines of a file in an array with awk

Hello, Is there any way in awk to put every line of a file in an array and so we can like this print the line we want. For example, if we have this file aaa eee bbb fff ccc ggg ddd hhh So we can print to the output the 3rd line only ccc ggg If it is possible, please put the... (7 Replies)
Discussion started by: rany1
7 Replies
Login or Register to Ask a Question