The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Read the csv file and assign the values in to variable rajbal Shell Programming and Scripting 11 06-27-2009 01:17 PM
Assign Values to variables from a text file sarsani Shell Programming and Scripting 3 06-26-2009 07:05 PM
How to assign a variable value to array? balamv Shell Programming and Scripting 2 06-06-2008 03:33 AM
how to assign multiple values in a pl/sql script vivek_damodaran Shell Programming and Scripting 2 05-29-2008 10:09 AM
how do u assign the values to different variables when it is presneted in one line?? SwetaShah High Level Programming 2 10-24-2005 09:56 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 10-29-2007
Syms Syms is offline
Registered User
  
 

Join Date: Oct 2007
Posts: 11
to assign cut values to an array

i need to seperate values seperated by delimiters and assign it to an array.. can u plz help me on that.

Variables = "asd,rgbh,(,rty,got,),sroe,9034,"
i need to assign the variables into arrays..
like..

var[0]=asd
var[1]=rgbh.. and so on
how do i do this. i need to reuse the values stored in the arrays.Is it possible.. ?
how do i do it using awk command?

Last edited by Syms; 10-29-2007 at 06:36 AM..
  #2 (permalink)  
Old 10-29-2007
matrixmadhan matrixmadhan is online now Forum Advisor  
Technorati Master
  
 

Join Date: Mar 2005
Location: leaf node in B+ tree
Posts: 2,952
Code:
echo "asd,rgbh,(,rty,got,),sroe,9034," | awk -F"," '{ split($0, arr, ","); }END{ for ( i in arr ) { print arr[i] } }'
  #3 (permalink)  
Old 10-29-2007
ghostdog74 ghostdog74 is offline Forum Advisor  
Registered User
  
 

Join Date: Sep 2006
Posts: 2,513
in bash
Code:
# IFS=,
# v="asd,rgbh,(,rty,got,),sroe,9034,"
# set -- $v
# echo $1
asd
# echo $3
(
# echo $#
8
# echo $@
asd rgbh ( rty got ) sroe 9034
  #4 (permalink)  
Old 10-29-2007
Syms Syms is offline
Registered User
  
 

Join Date: Oct 2007
Posts: 11
hi ghostdog,
i need the script in ksh .. can plz help me with that.. ?
  #5 (permalink)  
Old 10-29-2007
Syms Syms is offline
Registered User
  
 

Join Date: Oct 2007
Posts: 11
hi matrix.
i need to reuse the variables ..meaning... if i say echo "$arr[1]" i m getting the output as [1].. i want the value stored in arr[1]. how do i get that?
  #6 (permalink)  
Old 10-29-2007
matrixmadhan matrixmadhan is online now Forum Advisor  
Technorati Master
  
 

Join Date: Mar 2005
Location: leaf node in B+ tree
Posts: 2,952
Quote:
Originally Posted by Syms View Post
hi matrix.
i need to reuse the variables ..meaning... if i say echo "$arr[1]" i m getting the output as [1].. i want the value stored in arr[1]. how do i get that?
array variable within the awk contains the values and it could be readily used.
arr[1]
arr[2]

Not sure what you are looking for.
  #7 (permalink)  
Old 10-29-2007
Syms Syms is offline
Registered User
  
 

Join Date: Oct 2007
Posts: 11
hi madan .. i need to reuse the array variable outside the awk command..
echo ",asd,rgbh,(,rty,got,),sroe,9034," | awk -F"," '{ split($0, arr, ","); }END{ for ( i in arr ) { print arr[i] } }'
echo " $arr[1]"..
here the echo command does not give me the values stored in arr[1]..
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 07:30 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0