07-29-2009
Splitting a list @list by space delimiter so i can access it by using $list[0 ..1..2]
EDIT : This is for perl
@data2 = grep(/$data[1]/, @list_now);
This gives me @data2 as
Printing data2 11 testzone1 running /zones/testzone1 ***-*****-****-*****-***** native shared
But I really cant access data2 by its individual elements.
$data2[0] is the entire list, while $data[1],2,3... are null
How can I split @data2 by the space delimiter to get it into another array ?
My basic goal is to access 3rd field of data2 , "running " and store it in a variable.
-Shrikant
---------- Post updated at 12:58 PM ---------- Previous update was at 11:21 AM ----------
ok.. I had to store the @list in a scalar $variable and then split it by / / delimiter ..
Is this the only way out ?
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hey all, I have a directory (own by user: b; group: grpB) which I want a user (user: a; group: grpA) to be able to read and execute from, I wonder if I should add user a to this particular directory's ACL or that I would add group grpB to user a's subgroup?
I would like to know the difference... (3 Replies)
Discussion started by: mpang_
3 Replies
2. UNIX for Dummies Questions & Answers
Hello,
Here is my problem. there are two files.
first.txt <<< contains email address
======
abc@mail.com
abd@mail.com
abe@mail.com
second.txt <<< contains webpage links
========
http//www.test.com/abc/index.html
http://www.test.com/abd/index.html
http://www.test.com/abe/index.html... (2 Replies)
Discussion started by: paulds
2 Replies
3. UNIX for Dummies Questions & Answers
Hi there!
I have 150 txt files named chunk1, chunk2, ........., chunk150. I have a second file called string.txt with more than 1000 unique strings, house, dog, cat ... I want to know which command I should use to count how many times each string appears in the 150 files.
I have tried... (4 Replies)
Discussion started by: Pep Puigvert
4 Replies
4. UNIX for Advanced & Expert Users
Hi List is
000|2008-07-17|556543|RTJ|35-RTGJ|EYT
465|2008-11-10|567789|GHJ|45-DGHH|ETU
533|2008-09-06|567789|GHJ|45-DGHH|ETU
How does it do it?
sort -t ':' +0 -1 -n +1 -2 +2 -3 -o list list (6 Replies)
Discussion started by: gurvinder
6 Replies
5. Shell Programming and Scripting
I will be very grateful if someone can help me with bash shell script that does the following:
I have a list of filenames:
A01_155716
A05_155780
A07_155812
A09_155844
A11_155876
that are kept in different sub directories within my current directory. I want to find these files and copy... (3 Replies)
Discussion started by: manishabh
3 Replies
6. Shell Programming and Scripting
Does anyone have a good example? I am having trouble looping..
Thanks (1 Reply)
Discussion started by: mrlayance
1 Replies
7. Programming
hi all,
i need a c++ function which converts a linear list to circular.
presently i am working with two files. i.e., one linear list file. and one circular list file to do some operations. i thought it will be helpful if there is a function that converts a linear list to circular n undo the... (1 Reply)
Discussion started by: vidyaj
1 Replies
8. Shell Programming and Scripting
I have a file 1.txt with the below contents.
-----cat 1.txt-----
1234
5678
1256
1234
1247
-------------------
I have 3 more files in a folder
-----ls -lrt-------
A1.txt
A2.txt
A3.txt
-------------------
The contents of those three files are similar format with different data values... (8 Replies)
Discussion started by: realspirituals
8 Replies
9. UNIX for Dummies Questions & Answers
I have a string containing fields separated by space
Example
set sr="Fred Ted Joe Peter Paul Jean Chris Tim Tex"
and want to display it in a column format, for example to a maximum
of a window of 100 characters
And hopefully display some thing like
Fred Ted Joe ... (3 Replies)
Discussion started by: kristinu
3 Replies
10. Shell Programming and Scripting
Hello,
I have a folder with a massive amount of files, and I want to copy out a specific subset of the files to a new directory. I would like to use a text file with the filenames listed, but can't get it to work.
The thing I'm hung up on is that the folder names in the path can and do have... (5 Replies)
Discussion started by: twjolson
5 Replies
seek(n) Tcl Built-In Commands seek(n)
__________________________________________________________________________________________________________________________________________________
NAME
seek - Change the access position for an open channel
SYNOPSIS
seek channelId offset ?origin?
_________________________________________________________________
DESCRIPTION
Changes the current access position for channelId.
ChannelId must be an identifier for an open channel such as a Tcl standard channel (stdin, stdout, or stderr), the return value from an
invocation of open or socket, or the result of a channel creation command provided by a Tcl extension.
The offset and origin arguments specify the position at which the next read or write will occur for channelId. Offset must be an integer
(which may be negative) and origin must be one of the following:
start The new access position will be offset bytes from the start of the underlying file or device.
current The new access position will be offset bytes from the current access position; a negative offset moves the access position back-
wards in the underlying file or device.
end The new access position will be offset bytes from the end of the file or device. A negative offset places the access position
before the end of file, and a positive offset places the access position after the end of file.
The origin argument defaults to start.
The command flushes all buffered output for the channel before the command returns, even if the channel is in nonblocking mode. It also
discards any buffered and unread input. This command returns an empty string. An error occurs if this command is applied to channels
whose underlying file or device does not support seeking.
Note that offset values are byte offsets, not character offsets. Both seek and tell operate in terms of bytes, not characters, unlike
read.
EXAMPLES
Read a file twice:
set f [open file.txt]
set data1 [read $f]
seek $f 0
set data2 [read $f]
close $f
# $data1 == $data2 if the file wasn't updated
Read the last 10 bytes from a file:
set f [open file.data]
# This is guaranteed to work with binary data but
# may fail with other encodings...
fconfigure $f -translation binary
seek $f -10 end
set data [read $f 10]
close $f
SEE ALSO
file(n), open(n), close(n), gets(n), tell(n), Tcl_StandardChannels(3)
KEYWORDS
access position, file, seek
Tcl 8.1 seek(n)