02-08-2006
can you please elaborate a bit more, maybe with some sample input and output.
And will the no. of word be fixed in the string
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
to find log files modification, i want to select all the lines of a file behind a string (found by grep ?).
:rolleyes: (6 Replies)
Discussion started by: jpl35
6 Replies
2. Shell Programming and Scripting
could anyone help in running split cmd
split("String1,outputArray,"delimiter);
with sample script?.
for eg i have abc-def-ghi-sdf-
my ultimate aim of asking this is i have a string containing hypens,
i want to get the string before last n(2) Hypens (4 Replies)
Discussion started by: senthilk615
4 Replies
3. Shell Programming and Scripting
Hi,
I am new to scripting and need help splitting a string using space as the delimiter.
How can I do that?
I want the result to be stored in an Array.
I tried using
set -A arr $(echo $FILE)
echo $arr
The result of the above was ''.
Thanks. (2 Replies)
Discussion started by: newbie187
2 Replies
4. Shell Programming and Scripting
I need to split the string msu1_2
It should be generic for any string of the form msu<digits>_<digits>
so that i get $X =1 and $Y = 2
Please help
Thanks (5 Replies)
Discussion started by: asth
5 Replies
5. Shell Programming and Scripting
Hi,
can we split a number like this.. if i have something like 85743975945738, can it be converted as 8574-3975-945738 in ksh shell using single command...
Thanks! (5 Replies)
Discussion started by: nram_krishna@ya
5 Replies
6. Shell Programming and Scripting
Hi
I am facing a problem in spitting a string.
Here is the string
--------------------
subject1=10;subject2=30;subject3=40;subjectcode=10001;...
Now, I want only marks not the subject code. (there can be 'n' subjects)
ie.
10
30
40
My doubt
----------
How do I... (5 Replies)
Discussion started by: jionnet
5 Replies
7. Shell Programming and Scripting
I am trying to get some data from a file and print it on the same line.
I have a script that gets the body of emails and display it, but i want it to display each emails body in one line no matter how big it is. eg
insted of this
email1: bla bla bla
bla bla bla
bal
email2: bla bla bla... (7 Replies)
Discussion started by: maddog21
7 Replies
8. Shell Programming and Scripting
Hi,
We have a SunOS 5.10 Generic_142900-13 sun4v sparc SUNW,T5240.
I'm trying to find a way to split a string into 2 variables.
Ex:
parm1="192.168.1.101/parent/child"
What I need to do is split the string above into:
host="192.168.1.101"
location="parent/child"
I saw the... (3 Replies)
Discussion started by: adshocker
3 Replies
9. Shell Programming and Scripting
Hi All,
How to split the string KAR_Celltick_Ban_GSMGW3 and want to pickup the third filed. Sometime the string may be "KAR_Celltick_Ban" like this
Thanks in advance (1 Reply)
Discussion started by: sujit_kashyap
1 Replies
10. UNIX for Beginners Questions & Answers
value=malayalam
# i need to store the value in an array by splitting the character
#the output i need is
m
a
l
a
y
a
l
a
m
Please use CODE tags for output data as well as required by forum rules! (5 Replies)
Discussion started by: Meeran Rizvi
5 Replies
split(n) Tcl Built-In Commands split(n)
__________________________________________________________________________________________________________________________________________________
NAME
split - Split a string into a proper Tcl list
SYNOPSIS
split string ?splitChars?
_________________________________________________________________
DESCRIPTION
Returns a list created by splitting string at each character that is in the splitChars argument. Each element of the result list will con-
sist of the characters from string that lie between instances of the characters in splitChars. Empty list elements will be generated if
string contains adjacent characters in splitChars, or if the first or last character of string is in splitChars. If splitChars is an empty
string then each character of string becomes a separate element of the result list. SplitChars defaults to the standard white-space char-
acters.
EXAMPLES
Divide up a USENET group name into its hierarchical components:
split "comp.lang.tcl.announce" .
-> comp lang tcl announce
See how the split command splits on every character in splitChars, which can result in information loss if you are not careful:
split "alpha beta gamma" "temp"
-> al {ha b} {} {a ga} {} a
Extract the list words from a string that is not a well-formed list:
split "Example with {unbalanced brace character"
-> Example with {unbalanced brace character
Split a string into its constituent characters
split "Hello world" {}
-> H e l l o { } w o r l d
PARSING RECORD-ORIENTED FILES
Parse a Unix /etc/passwd file, which consists of one entry per line, with each line consisting of a colon-separated list of fields:
## Read the file
set fid [open /etc/passwd]
set content [read $fid]
close $fid
## Split into records on newlines
set records [split $content "
"]
## Iterate over the records
foreach rec $records {
## Split into fields on colons
set fields [split $rec ":"]
## Assign fields to variables and print some out...
lassign $fields
userName password uid grp longName homeDir shell
puts "$longName uses [file tail $shell] for a login shell"
}
SEE ALSO
join(n), list(n), string(n)
KEYWORDS
list, split, string
Tcl split(n)