Sponsored Content
Top Forums Shell Programming and Scripting Store the output values in array Post 302666199 by KarthikPS on Wednesday 4th of July 2012 01:46:09 AM
Old 07-04-2012
Bug 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.

Script should run one set by set. Once complete the first set, it should take second.

for i in ${name[@]}
do
echo $i
done

USAGE="$0 [initial] [name] [txt file] [value:0|1]

Those values should store in these variable, once its get first set, script should run follows, this should be in loop

Please give some idea
 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

how do I store the values in array using shell

Hi, Is is possible to get the value using shell script? x=1 y1 = 10 y2 = 15 y3 = 7 echo $y$x is giving y1 (variable name) but I need the value of y1 (i.e. 10 dynamically) Is there any solution? if so, please mail me at kkodava@maxis.com.my ... (2 Replies)
Discussion started by: krishna
2 Replies

2. UNIX for Dummies Questions & Answers

How to store the values in a file into an array

Hi, I do have a file and the contents are as follws: 10 20 30 40 50 Now I want to store those values into an array. How can be done this ?? (3 Replies)
Discussion started by: risshanth
3 Replies

3. UNIX for Dummies Questions & Answers

trouble using read to store values in variables from command output

I know there are caveats about using read in pipelines because read is treated by a subshell. I know this but I can't think of any way to accomplish this regardless, I'm still a rookie. I hope somebody will be able to interpret what it is that I'm trying to accomplish and correct me. ... (2 Replies)
Discussion started by: ProGrammar
2 Replies

4. Shell Programming and Scripting

Store values in an Array

Hi all. Well, I have the next code: I need to make an array with the values I have in the bucle, but just don't get it... Question is, how can I store in an array that values, and how can I display them with echo? (8 Replies)
Discussion started by: crcbad
8 Replies

5. Shell Programming and Scripting

Store all the passed arguments in an array and display the array

Hi I want to write a script which store all the parameters passed to the script into an array. Once it is stored I want scan through the array and and delete those files for last month present inside the directory. The files in directory is appneded with YYYY_MM_DD. I want to know how can I... (3 Replies)
Discussion started by: dgmm
3 Replies

6. Shell Programming and Scripting

How to store output of command to an array

Hello Guys, I am trying to store output of command to an array and then want to print, but it showing an error that "bad substitution". I am not getting why it's happening. Can anyone help me? #!/usr/bin/sh hr=0 min=0 i=1 last $1 | grep -w `date "+%b"` | grep -v '\(0:.*\)' | grep -vw sshd... (8 Replies)
Discussion started by: kasparov
8 Replies

7. Shell Programming and Scripting

Store values from a file into an array variable in Shell

Dear All, I have been trying to do a simple task of extracting 2 fields from the file (3 rows) and store it in an array variable. I tried with: #! /bin/bash ch=`cut -f10 tmp.txt` counter=0 for p in $pid do c=${ch} echo "$c ..$counter" counter=$((counter+1))... (2 Replies)
Discussion started by: ezhil01
2 Replies

8. Shell Programming and Scripting

How to read values and store in array?

I am reading a value from a file and want to store the value in a dynamic array as i don't know the number of occurrences of the value in that file. How can i do that and then later fetch that value from array (25 Replies)
Discussion started by: Prachi Gupta
25 Replies

9. Shell Programming and Scripting

ksh : need to store the output of a awk command to a array

I have awk command : awk -F ' ' '{ print $NF }' log filename And it gives the output as below: 06:00:00 parameters: SDS (2) no no no no doc=4000000000). information: (6 Replies)
Discussion started by: ramprabhum
6 Replies

10. Shell Programming and Scripting

awk loop using array:wish to store array values from loop for use outside loop

Here's my code: awk -F '' 'NR==FNR { if (/time/ && $5>10) A=$2" "$3":"$4":"($5-01) else if (/time/ && $5<01) A=$2" "$3":"$4-01":"(59-$5) else if (/time/ && $5<=10) A=$2" "$3":"$4":0"($5-01) else if (/close/) { B=0 n1=n2; ... (2 Replies)
Discussion started by: klane
2 Replies
ARRAY_FLIP(3)								 1							     ARRAY_FLIP(3)

array_flip - Exchanges all keys with their associated values in an array

SYNOPSIS
array array_flip (array $array) DESCRIPTION
array_flip(3) returns an array in flip order, i.e. keys from $array become values and values from $array become keys. Note that the values of $array need to be valid keys, i.e. they need to be either integer or string. A warning will be emitted if a value has the wrong type, and the key/value pair in question will not be included in the result. If a value has several occurrences, the latest key will be used as its value, and all others will be lost. PARAMETERS
o $array - An array of key/value pairs to be flipped. RETURN VALUES
Returns the flipped array on success and NULL on failure. EXAMPLES
Example #1 array_flip(3) example <?php $input = array("oranges", "apples", "pears"); $flipped = array_flip($input); print_r($flipped); ?> The above example will output: Array ( [oranges] => 0 [apples] => 1 [pears] => 2 ) Example #2 array_flip(3) example : collision <?php $input = array("a" => 1, "b" => 1, "c" => 2); $flipped = array_flip($input); print_r($flipped); ?> The above example will output: Array ( [1] => b [2] => c ) SEE ALSO
array_values(3), array_keys(3), array_reverse(3). PHP Documentation Group ARRAY_FLIP(3)
All times are GMT -4. The time now is 09:56 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy