Breaking a string into four different numbers


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Breaking a string into four different numbers
# 8  
Old 10-05-2009
Quote:
Originally Posted by Scrutinizer
If we use arrays there are also more direct ways of assigning, like
Code:
foo='1218141 1441 1664 122222'
typeset -a bar=($foo)

Excellent! I figured there should be something more straightforward way of assigning, but forget to mention it in my posting. One does learn something new everyday, right? :-)

Best regards,

pen

Last edited by pen; 10-05-2009 at 04:11 AM.. Reason: Missing endquote tag
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Sort only numbers within a string

Hi, I am having contents in a file like below, cat testfile rpool/swap rpool/swap14 rpool/swap2 rpool/swap3 I want to sort the above contents like, rpool/swap rpool/swap2 rpool/swap3 rpool/swap14 I have tried in this way, (7 Replies)
Discussion started by: Sumanthsv
7 Replies

2. Shell Programming and Scripting

Adding numbers in a string

I am writing a bash script on ubuntu11.10 I have some string having numbers and letter and want to add all the numbers together For example 1s2d23f I want to perform 1 + 2 + 23 and store it in a variable (3 Replies)
Discussion started by: kristinu
3 Replies

3. UNIX for Dummies Questions & Answers

Extracting numbers from a String

Hi all, I'm a new programmer to shell script... and I have no idea how to use substring. I want to extract the numbers from the following string and place it into a variable: "170 unique conformations found" The numbers can be more than three digits depending on the case. I just want to... (10 Replies)
Discussion started by: ah7391
10 Replies

4. Shell Programming and Scripting

Extracting numbers from a string

Hello Everyone, i have quick question. I have file names like: bin_map300.asc and I would like to extract grid300. My approach so far: name=bin_map300.asc echo ${name%%.*} echo ${name##*_} I am stuck combining the two. Any help would be appreciated. (3 Replies)
Discussion started by: creamcheese
3 Replies

5. Shell Programming and Scripting

Concatenating string with numbers

Hi, I want to display the string value with number value. I dont know how to display. Can anyone help me. This is my code export A=${file_name} echo $a $b $sum | awk '{ printf "%011.f,%014.f,%014.f\n", $1,$2,$3}' >> ${MRR_OUTPUT} the out put shold be ${A}, $a, $b filename,... (2 Replies)
Discussion started by: easterraj
2 Replies

6. Shell Programming and Scripting

get partial numbers from a string

Hi Everyone, I have: $val="QQ3_1899_CD4". The output will be: 1899. I did $val =~ /(\d+)/g; the output is 318994, then i use substr to get those 1899. This is not efficient. Is any simple way, like just one line can do? Thanks (1 Reply)
Discussion started by: jimmy_y
1 Replies

7. UNIX for Dummies Questions & Answers

Using Floating Numbers in String

Dear Unix Gurus, I have a list of files that I want to loop over....for example: sl40_z11.70.txt sl41_z11.40.txt sl42_z11.10.txt sl43_z10.80.txt using the script #!/bin/sh # echo -n "....enter first Z-coordinate position....."; read zpos q="scale=3; $zpos" p=0.3 #... (7 Replies)
Discussion started by: tintin72
7 Replies

8. Shell Programming and Scripting

How to sort a string with numbers

Hi, I need help to sort a file contents. I am using sort -r option to basically reverse the comparison in descending order. However, i found out that my file is not sorted according, can anyone please help. My data is something like:- Hello world 20.982342864 343 19.234355545 222... (5 Replies)
Discussion started by: ahjiefreak
5 Replies

9. Shell Programming and Scripting

to find numbers in a string

I writing my script and got stuck in this function. Can someone help me? I need to extract out the numbers inside a string. Ex: INPUT -> OUTPUT abcdef123 -> 123 abc123def -> 123 123abcdef -> 123 a123bc45d -> 123 45 abcdefghi -> -1 Thank you! (12 Replies)
Discussion started by: fongthai
12 Replies

10. Shell Programming and Scripting

How do i get numbers from a string?

Hi... I'm new here and i have a Q... How do i get only the number from a string? like from "rlvol11" i want to get 11 or from "lvol4" i want to get 4 what commands should i use at my script? thanx 4 the help! Eliraz. (13 Replies)
Discussion started by: eliraza6
13 Replies
Login or Register to Ask a Question
Unicode::GCString(3pm)					User Contributed Perl Documentation				    Unicode::GCString(3pm)

NAME
Unicode::GCString - String as Sequence of UAX #29 Grapheme Clusters SYNOPSIS
use Unicode::GCString; $gcstring = Unicode::GCString->new($string); DESCRIPTION
Unicode::GCString treats Unicode string as a sequence of extended grapheme clusters defined by Unicode Standard Annex #29 [UAX #29]. Grapheme cluster is a sequence of Unicode character(s) that consists of one grapheme base and optional grapheme extender and/or XprependX character. It is close in that people consider as character. Public Interface Constructors new (STRING, [LINEBREAK]) Constructor. Create new grapheme cluster string (Unicode::GCString object) from Unicode string STRING. Optional Unicode::LineBreak object LINEBREAK controls breaking features. copy Copy constructor. Create a copy of grapheme cluster string. Next position of new string is set at beginning. Sizes chars Instance method. Returns number of Unicode characters grapheme cluster string includes, i.e. length as Unicode string. columns Instance method. Returns total number of columns of grapheme clusters defined by built-in character database. For more details see "DESCRIPTION" in Unicode::LineBreak. length Instance method. Returns number of grapheme clusters contained in grapheme cluster string. Operations as String as_string """OBJECT""" Instance method. Convert grapheme cluster string to Unicode string explicitly. cmp (STRING) STRING "cmp" STRING Instance method. Compare strings. There are no oddities. One of each STRING may be Unicode string. concat (STRING) STRING "." STRING Instance method. Concatenate STRINGs. One of each STRING may be Unicode string. Note that number of columns (see columns()) or grapheme clusters (see length()) of resulting string is not always equal to sum of both strings. Next position of new string is that set on the left value. join ([STRING, ...]) Instance method. Join STRINGs inserting grapheme cluster string. Any of STRINGs may be Unicode string. substr (OFFSET, [LENGTH, [REPLACEMENT]]) Instance method. Returns substring of grapheme cluster string. OFFSET and LENGTH are based on grapheme clusters. If REPLACEMENT is specified, substring is replaced by it. REPLACEMENT may be Unicode string. Operations as Sequence of Grapheme Clusters as_array "@{"OBJECT"}" as_arrayref Instance method. Convert grapheme cluster string to an array of grapheme clusters. eos Instance method. Test if current position is at end of grapheme cluster string. item ([OFFSET]) Instance method. Returns OFFSET-th grapheme cluster. If OFFSET was not specified, returns next grapheme cluster. next "<"OBJECT">" Instance method, iterative. Returns next grapheme cluster and increment next position. pos ([OFFSET]) Instance method. If optional OFFSET is specified, set next position by it. Returns next position of grapheme cluster string. Methods palanned to be deprecated flag ([OFFSET, [VALUE]]) Instance method. Get or set flag value of OFFEST-th grapheme cluster. If OFFSET was not specified, returns flag value of next grapheme cluster. Flag value is an non-zero integer not greater than 255 and initially is 0. Predefined flags are: Unicode::LineBreak::ALLOW_BEFORE Allow line breaking just before this grapheme cluster. Unicode::LineBreak::PROHIBIT_BEFORE Prohibit line breaking just before this grapheme cluster. lbclass ([OFFSET]) Returns Line Breaking Class (See Unicode::LineBreak) of the first character of OFFSET-th grapheme cluster. If OFFSET was not specified, returns class of next grapheme cluster. Note: Use lbc(). lbclass_ext ([OFFSET]) Returns Line Breaking Class (See Unicode::LineBreak) of the last grapheme extender of OFFSET-th grapheme cluster. If there are no grapheme extenders or its class is CM, value of lbclass() is returned. Note: Use lbcext(). Miscelaneous lbc Returns Line Breaking Class (See Unicode::LineBreak) of the first character of first grapheme cluster. lbcext Returns Line Breaking Class (See Unicode::LineBreak) of the last grapheme extender of last grapheme cluster. If there are no grapheme extenders or its class is CM, value of last grapheme base will be returned. CAVEATS
o The grapheme cluster should not be referred to as "grapheme" even though Larry does. o On Perl around 5.10.1, implicit conversion from Unicode::GCString object to Unicode string sometimes let "utf8_mg_pos_cache_update" cache be confused. For example, instead of doing $sub = substr($gcstring, $i, $j); do $sub = substr("$gcstring", $i, $j); $sub = substr($gcstring->as_string, $i, $j); o This module implements default algorithm for determining grapheme cluster boundaries. Tailoring mechanism has not been supported yet. VERSION
Consult $VERSION variable. Development versions of this module may be found at http://hatuka.nezumi.nu/repos/Unicode-LineBreak/ <http://hatuka.nezumi.nu/repos/Unicode-LineBreak/>. SEE ALSO
[UAX #29] Mark Davis (2009-2010). Unicode Standard Annex #29: Unicode Text Segmentation, Revision 15-17. <http://www.unicode.org/reports/tr29/>. AUTHOR
Hatuka*nezumi - IKEDA Soji <hatuka(at)nezumi.nu> COPYRIGHT
Copyright (C) 2009-2012 Hatuka*nezumi - IKEDA Soji. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.14.2 2012-03-24 Unicode::GCString(3pm)