Sponsored Content
Top Forums Shell Programming and Scripting KSH: Split String into smaller substrings based on count Post 302703251 by nitrobass24 on Wednesday 19th of September 2012 01:59:56 PM
Old 09-19-2012
Its not too big for a shell variable....Its in a shell variable.

I just want it smaller so i can put it into an array.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

KSH split string into variables

Hello, I am an intermediate scripter. I can usually find and adapt what I need by searching through previous postings, but I'm stumped. I have a string with the format "{Name1 Release1 Type1 Parent1} {Name2 Release2 Type2 Parent2}". It is being passed as an argument into a ksh script. I need to... (5 Replies)
Discussion started by: drd_2b
5 Replies

2. Shell Programming and Scripting

[KSH] Split string into array

Hi, Is there any way to convert a string into an array in KSH? In other words I want to split the string like this: STRING="one two three four" into an array of 4 values splitting on white space. The array should be similar to the one that would be created with the following command: ... (3 Replies)
Discussion started by: piooooter
3 Replies

3. Shell Programming and Scripting

How to split the String based on condition?

hi , I have a String str="/opt/ibm/lotus/ibw/latest" or ="/opt/lotus/ibw/latest" this value is dynamic..I want to split this string into 2 strings 1. /opt/ibm/lotus(/opt/lotus) this string must ends with "lotus" 2./ibw/latest can any body help me on this? Regards, sankar (2 Replies)
Discussion started by: sankar reddy
2 Replies

4. Shell Programming and Scripting

filtering out duplicate substrings, regex string from a string

My input contains a single word lines. From each line data.txt prjtestBlaBlatestBlaBla prjthisBlaBlathisBlaBla prjthatBlaBladpthatBlaBla prjgoodBlaBladpgoodBlaBla prjgood1BlaBla123dpgood1BlaBla123 Desired output --> data_out.txt prjtestBlaBla prjthisBlaBla... (8 Replies)
Discussion started by: kchinnam
8 Replies

5. Shell Programming and Scripting

split file based on group count

Hi, can some one please help me to split the file based on groups. like in the below scenario x indicates the begining of the group and the file should be split each with 2 groups below there are 10 groups it should create 5 files. could you please help? (4 Replies)
Discussion started by: hitmansilentass
4 Replies

6. Shell Programming and Scripting

Help needed - Split large file into smaller files based on pattern match

Help needed urgently please. I have a large file - a few hundred thousand lines. Sample CP START ACCOUNT 1234556 name 1 CP END ACCOUNT CP START ACCOUNT 2224444 name 1 CP END ACCOUNT CP START ACCOUNT 333344444 name 1 CP END ACCOUNT I need to split this file each time "CP START... (7 Replies)
Discussion started by: frustrated1
7 Replies

7. Shell Programming and Scripting

A command to split a file into two based on a string

Hello What command can i use to split a tab delimited txt file into two files base on the occurrence of a string my file name is EDIT.txt The content of file is below XX 1234 PROCEDURES XY 1634 PROCEDURES XM 1245 CODES XZ 1256 CODES It has more than a million record If there is... (16 Replies)
Discussion started by: madrazzii
16 Replies

8. Shell Programming and Scripting

How to Split File based on String?

hi , The scenario is like this, i have a large text files (max 5MB , about 5000 file per day ), Inside almost each line of this file there is a tag 3100.2.22.1 (represent Call_Type) , i need to generate many filess , each one with distinct (3100.2.22.1 Call_Type ) , and one more file to... (3 Replies)
Discussion started by: OTNA
3 Replies

9. Shell Programming and Scripting

awk - split data based on the count

Greetings Experts, I am generating a validation query through awk and facing an issue, which I need to overcome by splitting the data based on the pattern matching count in the value of an array. File1 -- Table11@column1@date@Table21@column1@varchar(10)@d;... (4 Replies)
Discussion started by: chill3chee
4 Replies

10. Shell Programming and Scripting

Split files based on row delimiter count

I have a huge file (around 4-5 GB containing 20 million rows) which has text like: <EOFD>11<EOFD>22<EORD>2<EOFD>2222<EOFD>3333<EORD>3<EOFD>44<EOFD>55<EORD>66<EOFD>888<EOFD>9999<EORD> Actually above is an extracted file from a Sql Server with each field delimited by <EOFD> and each row ends... (8 Replies)
Discussion started by: amvip
8 Replies
Sort::Key::Natural(3pm) 				User Contributed Perl Documentation				   Sort::Key::Natural(3pm)

NAME
Sort::Key::Natural - fast natural sorting SYNOPSIS
use Sort::Key::Natural qw(natsort); my @data = qw(foo1 foo23 foo6 bar12 bar1 foo bar2 bar-45 foomatic b-a-r-45); my @sorted = natsort @data; print "@sorted "; # prints: # b-a-r-45 bar1 bar2 bar12 bar-45 foo foo1 foo6 foo23 foomatic use Sort::Key::Natural qw(natkeysort); my @objects = (...); my @sorted = natkeysort { $_->get_id } @objects; DESCRIPTION
This module extends the Sort::Key family of modules to support natural sorting. Under natural sorting, strings are split at word and number boundaries, and the resulting substrings are compared as follows: o numeric substrings are compared numerically o alphabetic substrings are compared lexically o numeric substrings come always before alphabetic substrings Spaces, symbols and non-printable characters are only considered for splitting the string into its parts but not for sorting. For instance "foo-bar-42" is broken in three substrings "foo", "bar" and 42 and after that the dashes are ignored. Note, that the sorting is case sensitive. To do a case insensitive sort you have to convert the keys explicitly: my @sorted = natkeysort { lc $_ } @data Also, once this module is loaded, the new type "natural" (or "nat") will be available from Sort::Key::Maker. For instance: use Sort::Key::Natural; use Sort::Key::Maker i_rnat_keysort => qw(integer -natural); creates a multikey sorter "i_rnat_keysort" accepting two keys, the first to be compared as an integer and the second in natural descending order. There is also an alternative set of natural sorting functions that recognize floating point numbers. They use the key type "natwf" (abreviation of "natural_with_floats"). FUNCTIONS the functions that can be imported from this module are: natsort @data returns the elements of @data sorted in natural order. rnatsort @data returns the elements of @data sorted in natural descending order. natkeysort { CALC_KEY($_) } @data returns the elements on @array naturally sorted by the keys resulting from applying them "CALC_KEY". rnatkeysort { CALC_KEY($_) } @data is similar to "natkeysort" but sorts the elements in descending order. natsort_inplace @data rnatsort_inplace @data natkeysort_inplace { CALC_KEY($_) } @data rnatkeysort_inplace { CALC_KEY($_) } @data these functions are similar respectively to "natsort", "rnatsort", "natsortkey" and "rnatsortkey", but they sort the array @data in place. $key = mkkey_natural $string given $string, returns a key that can be compared lexicographically to another key obtained in the same manner, results in the same order as comparing the former strings as in the natural order. If the argument $key is not provided it defaults to $_. natwfsort @data rnatwfsort @data natkeywfsort { CALC_KEY($_) } @data rnatkeywfsort { CALC_KEY($_) } @data natwfsort_inplace @data rnatwfsort_inplace @data natkeywfsort_inplace { CALC_KEY($_) } @data rnatkeywfsort_inplace { CALC_KEY($_) } @data mkkey_natural_with_floats $key this ugly named set of functions perform in the same way as its s/natwf/nat/ counterpart with the difference that they honor floating point numbers embeded inside the strings. In this context a floating point number is a string matching the regular expression "/[+-]?d+(.d*)?/". Note that numbers with an exponent part (i.e. "1.12E-12") are not recognized as such. Note also that numbers without an integer part (i.e. .2 or "-.12") are not supported either. SEE ALSO
Sort::Key, Sort::Key::Maker. Other module providing similar functionality is Sort::Naturally. COPYRIGHT AND LICENSE
Copyright (C) 2006, 2012 by Salvador Fandin~o, <sfandino@yahoo.com>. This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.4 or, at your option, any later version of Perl 5 you may have available. perl v5.14.2 2012-06-30 Sort::Key::Natural(3pm)
All times are GMT -4. The time now is 11:42 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy