Sponsored Content
Top Forums Shell Programming and Scripting How to insert an array element within regex? Post 302852013 by pravin27 on Tuesday 10th of September 2013 09:39:52 AM
Old 09-10-2013
Try this,
Code:
echo "22030046075451230200460754516925090046075451" | awk -F "2[2345]" 'BEGIN{p[22]="MJS,"
p[23]="UYT,"
p[24]="WER,"
p[25]="PIL,"
}
{a=substr($0,1,2); printf p[a];for (i=2;i<=NF;i++) {
len=length($i);lntotal+=len+2; if (len >= 12 ) { printf substr($i,1,10)","substr($i,11,2);} if (len == 14 ){ printf ","substr($i,13);} b=substr($0,lntotal+1,2);if(p[b]) { printf ", "p[b]};
} printf "\n";
}'

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

accessing my first element of array

Hello everyonel, I have an array set like so num=4 read name arr=name I go through while loop to assign different values to different array element from 1 to 4. when I try to access the FIRST element of the array I get the last one first. Like if I say ${arr} it will show the last element... (4 Replies)
Discussion started by: afadaghi
4 Replies

2. Shell Programming and Scripting

Reading Of Array Element in Unix

Hi, I am using the following command to initialize and array # arr=ffffff00 # echo $arr ffffff00 my requirement is i want to fetch the one by one character from array. I don't know how to fetch one by one charcter from array. Please i need an help. Thank you very much Ravi R N (2 Replies)
Discussion started by: ravi_rn
2 Replies

3. Shell Programming and Scripting

Shift array element

I want to delete and 0th element of array in shell scrpit and also shift all others to one level up. (2 Replies)
Discussion started by: darshakraut
2 Replies

4. Shell Programming and Scripting

HELP unsetting array element in loop

I have a loop and I need to be able to unset the array element that I am currently accessing in it. I was thinking of making a counter that increments with the loop and doing unset $dirs but if I do that I am not sure if the other members of the array would get shifted down in index (meaning that... (2 Replies)
Discussion started by: msf5042
2 Replies

5. Shell Programming and Scripting

remove an element from array

I need to remove an element from the below array variable TABLENAME. #!/bin/ksh set -A TABLENAME "mirf roxar keke mirs" echo "the array is ${TABLENAME}" If i need to remove say keke and have the final TABLENAME as below, how this could be achieved. Pls throw some light. echo "Modified... (3 Replies)
Discussion started by: michaelrozar17
3 Replies

6. Shell Programming and Scripting

Multiplying array element

I am trying to take all the elements of an array and multiply them by 2, and then copy them to a new array. Here is what I have i=0 for true in DMGLIST do let DMGSIZES2="${DMGSIZES}"*2 let i++ done unset i echo ${DMGSIZES2} It does the calculation correctly for the first element,... (7 Replies)
Discussion started by: nextyoyoma
7 Replies

7. Shell Programming and Scripting

ksh insert element in array

Hi all, I need help with the following scenario in ksh. If the number of elements contained by arrayA is 11 I need to insert a zero as the element arrayA then print all arrayA elements separated by comma. Appreciate your help. (9 Replies)
Discussion started by: ejianu
9 Replies

8. Shell Programming and Scripting

Bash 3.2 - Array / Regex - IF 3rd member in array ends in 5 digits then do somthing...

Trying to do some control flow parsing based on the index postion of an array member. Here is the pseudo code I am trying to write in (preferably in pure bash) where possible. I am thinking regex with do the trick, but need a little help. pesudo code if == ENDSINFIVEINTS ]]; then do... (4 Replies)
Discussion started by: briandanielz
4 Replies

9. UNIX for Advanced & Expert Users

Array Element

This question is for someone that's more familiar with Array Element. I need to know if the maximum array element that can be assigned is 1024 and if its so, Is there a workaround solution when the counter exceeded 1024? param_array="$param_nam" counter=$counter+1 #to avoid space... (3 Replies)
Discussion started by: cumeh1624
3 Replies

10. Shell Programming and Scripting

How to insert a CSV within xml element tag using Python?

Hi Team, I have a CSV file which I have to read through and needs to insert the content within an XML file using Python ONLY ( as most of the code base we have in python only). I managed to find the first part, missing how to insert to XML under "specific" tags. cat input.csv... (0 Replies)
Discussion started by: panyam
0 Replies
tapset::string(3stap)													     tapset::string(3stap)

NAME
tapset::string - systemtap string tapset DESCRIPTION
strlen Returns the length of a string See function::strlen(3stap) for details. substr Returns a substring See function::substr(3stap) for details. stringat Returns the char at a given position in the string See function::stringat(3stap) for details. isinstr Returns whether a string is a substring of another string See function::isinstr(3stap) for details. text_str Escape any non-printable chars in a string See function::text_str(3stap) for details. text_strn Escape any non-printable chars in a string See function::text_strn(3stap) for details. - strtol Convert a string to a long See function::-strtol(3stap) for details. isdigit Checks for a digit See function::isdigit(3stap) for details. SEE ALSO
function::strlen(3stap), function::substr(3stap), function::stringat(3stap), function::isinstr(3stap), function::text_str(3stap), function::text_strn(3stap), function::-(3stap), function::strtol(3stap), function::isdigit(3stap), stap(1), stapprobes(3stap) IBM
--- tapset::string(3stap)
All times are GMT -4. The time now is 01:22 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy