How to store/read multiple values from a varible


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers How to store/read multiple values from a varible
# 1  
Old 07-04-2012
Java How to store/read multiple values from a varible

Hi,
when I enter '
Code:
ps -ef| grep process_name'/'psu | grep process_name

', i am getting multiple number of lines output( i mean multiple no of processes).how can i store it one by one and echo it in the same way(one by one).

part of script is

Code:
var1=$(remsh hostname -l username ps -ef|grep process_name |grep -v grep)
echo $var1

i am getting the output in a single line.

Last edited by Scrutinizer; 07-05-2012 at 02:25 AM.. Reason: code tags
# 2  
Old 07-05-2012
try echo with double quotes

Code:
 
echo "$var1"

# 3  
Old 07-08-2012
thank you.
it worked
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

awk GSUB read field values from multiple text files

My program run without error. The problem I am having. The program isn't outputting field values with the column headers to file.txt. Each of the column headers in file.txt has no data. MEMSIZE SECOND SASFoundation Filename The output results in file.txt should show: ... (1 Reply)
Discussion started by: dellanicholson
1 Replies

2. UNIX for Dummies Questions & Answers

Read in Multiple log files and output selected variables and values to cvs file

I have several problems with my problems: I hope you can help me. 1) the If else statement I am getting an error message. My syntax must be incorrect because the entire statement is throwing an error. For example in filew.log if these items don't exist Memsize, SASFoundation and also if... (0 Replies)
Discussion started by: dellanicholson
0 Replies

3. Shell Programming and Scripting

Read multiple values into one variable

Hello everybody, I am trying to assign multiple values from text into a single variable in bash. Source TXT: 1 THIS IS THE ENTITY1 NAME1 2 THIS IS THE ENTITY2 NAME2 3 THIS IS THE ENTITY3 NAME3 while read id entity name do printf "$id" "$entity" "$name" done <... (2 Replies)
Discussion started by: mrcrowley
2 Replies

4. Shell Programming and Scripting

Read record from the text file contain multiple separated values & assign those values to variables

I have a file containing multiple values, some of them are pipe separated which are to be read as separate values and some of them are single value all are these need to store in variables. I need to read this file which is an input to my script Config.txt file name, first path, second... (7 Replies)
Discussion started by: ketanraut
7 Replies

5. Shell Programming and Scripting

[SOLVED] UNIX FOR loop to read a variable with multiple values

Hi, I have a variable which stores file names as a result of find command. I need to delete all these files one by one, i.e. by a loop. Can anyone tell me how can it be done? The variable f2d has the file names like these abc.txt bcd.txt fff.txt gef.txt Now I have used a loop as... (12 Replies)
Discussion started by: jhilmil
12 Replies

6. 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

7. Shell Programming and Scripting

Read multiple values from sqlplus in perl

Hello Need your kind support to solve the below issue I am returning oracle column value via sqlplus in the below code my $sqlplus_settings = ''; my $newval = qx { sqlplus -s $connect_string <<EOF set pages 0 feed off $sqlplus_settings select (rcrd_cnt) from... (4 Replies)
Discussion started by: Pratik4891
4 Replies

8. 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

9. Shell Programming and Scripting

split varibles and store fields into shell varible array

I need to split a long varible which is a whole line read from a file into fields and store them in an array, the fields are delimited by pipe and a field may contain white spaces. I tried the following concept test and it has problem with field 5 which contain a space, appearently so because... (3 Replies)
Discussion started by: gratus
3 Replies

10. Shell Programming and Scripting

Using varible/varible substitution in Perl/sed Search & Replace

Hi, I have a program that searches for a particular string patten. I am however having difficulty passing the varible $i (in a loop) as the string pattern to replace. Using either perl or sed search and replace statements, I get the same kinda result. For example, using the perl: for i in... (3 Replies)
Discussion started by: Breen
3 Replies
Login or Register to Ask a Question