Sponsored Content
Top Forums Shell Programming and Scripting split varibles and store fields into shell varible array Post 302140259 by vgersh99 on Thursday 11th of October 2007 02:14:25 PM
Old 10-11-2007
or a bit simpler:
Code:
#!/bin/ksh

var='word1#word2|word3/word4|word5.word6|word7_word8|word9 word10|word11|word12'

IFS='|'; set -A arr $(echo "$var")
i=0
while (( i <= 6 ))
do
    echo "i=>[$i] (${arr[$i]})"
    ((i=i+1))
done

 

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. Shell Programming and Scripting

How to store query multiple result in shell script variable(Array)

:) Suppose,I have one table A. Table A have one column. Table A have 10 rows. I want this 10 rows store into shell script variable. like #!/bin/ksh v_shell_var=Hi here in call oracle , through loop How can I store table A's 10 rows into v_shell_var (Shell Script Array). Regards, Div (4 Replies)
Discussion started by: div_Neev
4 Replies

3. Shell Programming and Scripting

How to store contents of a command in array of variables in shell script?

I want to store contents of command dir in array of variables For eg: dir contents are command d2 demovi~ file inven java new untitled folder d1 demovi er1 filename inven~ myfiles ubuntu desktop xmms ----------------------------------- I... (3 Replies)
Discussion started by: netresearch
3 Replies

4. Shell Programming and Scripting

how to split the row(array) in to fields and store in to oracle database in unix

Hi, the csv file with the delimeter #. A#B#C#D#E#F#G#H 1#2#3#4#5#6#7#8 Z#x#c#V 7#2#8#9 N. I want to read the file line by line and store in rowarray. then the rowarray content should be spilt or made to fields using the delimeter #. i am not sure can we store the fields in to... (3 Replies)
Discussion started by: barani75
3 Replies

5. Shell Programming and Scripting

how to spilit a row into fields and store the field content to the array

consider this is a line A#B#C#D#E#F#G#H note the delimeter is # i want to cut or spilt in to fields using the delimeter # and to store in an array. like this array=A array=B array=C array=D array=E and the array content should be displayed. echo "${array}" echo "${array}"... (5 Replies)
Discussion started by: barani75
5 Replies

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

7. Shell Programming and Scripting

split string into array in shell

Hi all, I want to split a string into array based on given delimiter, for example: String: "foo|bar|baz" with delimiter "|" into array: strArr to strArr with values foo, bar and baz. Thanks a lot. Roy987 (5 Replies)
Discussion started by: Roy987
5 Replies

8. UNIX for Dummies Questions & Answers

How to store/read multiple values from a varible

Hi, when I enter '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 var1=$(remsh hostname -l username ps -ef|grep... (2 Replies)
Discussion started by: jeanzibbin
2 Replies

9. Shell Programming and Scripting

create an array which can store the strings from the user input in shell script

I want to create an array which can store the strings from the user input in shell script . example :- I want to store the 5 fruits name in a single array which the user provides . (1 Reply)
Discussion started by: Pkast
1 Replies

10. Shell Programming and Scripting

Shell script to loop and store in array

I'm trying to achieve the follwoinig with no luck. Find the directories that are greater than 50GB in size and pick the owner of the directory as I would like to send an alert notification. du -sh * | sort -rh 139G Dir_1 84G Dir_2 15G Dir_3 ls -l Dir_1 drwx------ 2... (3 Replies)
Discussion started by: 308002184
3 Replies
pydhcplib.strlist(3)						     PYDHCPLIB						      pydhcplib.strlist(3)

NAME
pydhcplib.strlist - Internal type of pydhcplib for lists of bytes processing. SYNOPSIS
from pydhcplib.type_hw_addr import hwmac a = strlist() a = strlist([100,100,10,42,44,26]) DESCRIPTION
The class pydhcplib.strlist is an specific type of pydhcplib. It exist in order to simplify processing of raw data from network. When a dhcp packet dhcp is received, it's a succession of approximately 300 bytes. Within pydhcplib these data are transformed in an intermediary form of type "strlist" in order to facilitate their handling. This intermediary form will eventually be suppressed in the stable versions of pydhcplib to speedup the processing time, but backward compatibility will be assured. The pydhcplib.strlist class creation argument can be a list of numbers whose value goes from 0?55. The pydhcplib.strlist class creation argument can be a string of ASCII character. METHODS
The implemented methods in this type are mostly comparison methods (= =, >, etc...) else : str() convert the address into a printable string type. list() convert the address into a list of bytes. EXAMPLES
Example program strlist_example.py : from pydhcplib.type_strlist import strlist word = strlist() word1 = strlist("azerty") word2 = strlist("qwerty") word3 = strlist([97, 122, 101, 114, 116, 121]) print "a0 : ",word print "a1 : ",word1 print "a2 : ",word2 print "a3 : ",word3 if word1 == word2 : print "test 1 : ",word1, "==",word2 else : print "test 1 : " ,word1, "!=",word2 if word1 == word3 : print "test 2 : ", word1, "==",word3 else : print "test 2 : ", word1, "!=",word3 SEE ALSO
pydhcp(8), pydhcplib.hwmac(3), pydhcplib.ipv4(3), pydhcplib.strlist(3), pydhcplib.DhcpPacket(3), pydhcplib.DhcpBasicPacket(3), pydhc- plib.DhcpNetwork(3), pydhcplib.DhcpClient(3), pydhcplib.DhcpRawClient(3), pydhcplib.DhcpDerver(3) BUGS
See http://pydhcplib.tuxfamily.org/ for more information. AUTHOR
Mathieu Ignacio (mignacio[AT]april.org) pydhcplib.strlist(3)
All times are GMT -4. The time now is 03:58 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy