Sponsored Content
Top Forums Shell Programming and Scripting Map values of blocks in a single line Post 302748723 by Yoda on Wednesday 26th of December 2012 11:54:33 PM
Old 12-27-2012
Code:
awk  'BEGIN {
 print "IMSIS,M,NA,OBA,BO,PLMN,MAPVER,NRRG,CBA,CBAZ,CAMEL,INOPER,OWNMS,NATMS,ERIS,STALL"
 v1=v2=v3=v4=v5=v6=v7=v8=v9=v10=v11=v12=v13=v14=v15=v16=""; }
  /IMSIS=/ { split($0,arr,"="); v1=arr[2]; gsub(";","",v1); }
  NF==4 && !/IMSIS/ { v2=$2; v3=$3; split($4,arr,"-"); v4=arr[2]; }
  NF==1 && /BO/ { if($0 ~ /-/) { split($0,arr,"-"); v5=arr[2]; } else v5=1; }
  NF==1 && /PLMN/ { if($0 ~ /-/) { split($0,arr,"-"); v6=arr[2]; } else v6=1; }
  NF==1 && /MAPVER/ { if($0 ~ /-/) { split($0,arr,"-"); v7=arr[2]; } else v7=1; }
  NF==1 && /NRRG/ { if($0 ~ /-/) { split($0,arr,"-"); v8=arr[2]; } else v8=1; }
  NF==1 && /CBA/ { if($0 ~ /-/) { split($0,arr,"-"); v9=arr[2]; } else v9=1; }
  NF==1 && /CBAZ/ { if($0 ~ /-/) { split($0,arr,"-"); v10=arr[2]; } else v10=1; }
  NF==1 && /CAMEL/ { if($0 ~ /-/) { split($0,arr,"-"); v11=arr[2]; } else v11=1; }
  NF==1 && /INOPER/ { if($0 ~ /-/) { split($0,arr,"-"); v12=arr[2]; } else v12=1; }
  NF==1 && /OWNMS/ { if($0 ~ /-/) { split($0,arr,"-"); v13=arr[2]; } else v13=1; }
  NF==1 && /NATMS/ { if($0 ~ /-/) { split($0,arr,"-"); v14=arr[2]; } else v14=1; }
  NF==1 && /ERIS/ { if($0 ~ /-/) { split($0,arr,"-"); v15=arr[2]; } else v15=1; }
  NF==1 && /STALL/ { if($0 ~ /-/) { split($0,arr,"-"); v16=arr[2]; } else v16=1; }
  /END/ {
   if(v2=="")
      printf ("%s,%s\n",v1,"UNIDENTIFIED");
   else printf ("%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s\n", v1,v2,v3,v4,v5,v6,v7,v8,v9,v10,v11,v12,v13,v14,v15,v16);
  v1=v2=v3=v4=v5=v6=v7=v8=v9=v10=v11=v12=v13=v14=v15=v16="";
}' filename

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Find 5 lines and replace with 18 line in sql file where it contains multiple blocks.

My sql file xyz_abc.sql in this file there are multiple sql block in this block I need to find the following block rem Subset Rows (&&tempName.*) CREATE VIEW &&tempName.* AS SELECT * FROM &&tempName.* WHERE f is not null and replace with following code rem Subset Rows... (9 Replies)
Discussion started by: Zaheer.mic
9 Replies

2. Shell Programming and Scripting

how to split this file into blocks and then send these blocks as input to the tool called Yices?

Hello, I have a file like this: FILE.TXT: (define argc :: int) (assert ( > argc 1)) (assert ( = argc 1)) <check> # (define c :: float) (assert ( > c 0)) (assert ( = c 0)) <check> # now, i want to separate each block('#' is the delimeter), make them separate files, and then send them as... (5 Replies)
Discussion started by: paramad
5 Replies

3. Shell Programming and Scripting

How to map the values of an array in perl?

Hi, I have 2 arrays: @names=qw(amith veena chaitra); @files=qw(file.txt file1.txt file3.txt); There is one to one relationship between names and files. There needs to be mapping created between names and files. The output should be like this: amith --> file.txt veena --->... (3 Replies)
Discussion started by: vanitham
3 Replies

4. Shell Programming and Scripting

Multiple lines in a single column to be merged as a single line for a record

Hi, I have a requirement with, No~Dt~Notes 1~2011/08/1~"aaa bbb ccc ddd eee fff ggg hhh" Single column alone got splitted into multiple lines. I require the output as No~Dt~Notes 1~2011/08/1~"aaa<>bbb<>ccc<>ddd<>eee<>fff<>ggg<>hhh" mean to say those new lines to be... (1 Reply)
Discussion started by: Bhuvaneswari
1 Replies

5. Shell Programming and Scripting

Show distinct values of a key from a single line

Hi All, I am newbie to linux. Can somebody help me with following requirement. I have one huge line. I have to find out particular key/value pair to see the distinct value of that key. Portion of the String:- <?xml version="1.1" encoding="UTF-8"?> <Data><Val Ti="1342750845538" Du="0"... (5 Replies)
Discussion started by: kmajumder
5 Replies

6. Shell Programming and Scripting

Row blocks to column blocks

Hello, Searched for a while and found some "line-to-column" script. My case is similar but with multiple fields each row: S02 Length Per S02 7043 3.864 S02 54477 29.89 S02 104841 57.52 S03 Length Per S03 1150 0.835 S03 1321 0.96 S03 ... (9 Replies)
Discussion started by: yifangt
9 Replies

7. Shell Programming and Scripting

sed multiple multi line blocks of text containing pattern

Hi, I have a log file which has sessionids in it, each block in the log starts with a date entry, a block may be a single line or multiple lines. I need to sed (or awk) out the lines/blocks with that start with a date and include the session id. The files are large at several Gb. My... (3 Replies)
Discussion started by: andyatit
3 Replies

8. Shell Programming and Scripting

sed - filter blocks between single delimiters matching a pattern

Hi! I have a file with the following format:CDR ... MSISDN=111 ... CDR ... MSISDN=xxx ... CDR ... MSISDN=xxx ... CDR ... MSISDN=111 (2 Replies)
Discussion started by: Flavius
2 Replies

9. Shell Programming and Scripting

Bring values in the second column into single line (comma sep) for uniq value in the first column

I want to bring values in the second column into single line for uniq value in the first column. My input jvm01, Web 2.0 Feature Pack Library jvm01, IBM WebSphere JAX-RS jvm01, Custom01 Shared Library jvm02, Web 2.0 Feature Pack Library jvm02, IBM WebSphere JAX-RS jvm03, Web 2.0 Feature... (10 Replies)
Discussion started by: kchinnam
10 Replies

10. Solaris

Can I run repair on lot of blocks with single command ?

Hi, I have Solaris-10 OS on T5220. Both local disks were mirrored under SVM. Somehow when one disk gone bad (c0t1d0), other disk (c0t0d0) also got lot of bad block. We have readable data only on c0t0d0, but as soon as server comes after, it hangs when I run few commands because of read errors,... (1 Reply)
Discussion started by: solaris_1977
1 Replies
PS_SETPOLYDASH(3)							 1							 PS_SETPOLYDASH(3)

ps_setpolydash - Sets appearance of a dashed line

SYNOPSIS
bool ps_setpolydash (resource $psdoc, float $arr) DESCRIPTION
Sets the length of the black and white portions of a dashed line. ps_setpolydash(3) is used to set more complicated dash patterns. PARAMETERS
o $psdoc - Resource identifier of the postscript file as returned by ps_new(3). o $arr -$arr is a list of length elements alternately for the black and white portion. RETURN VALUES
Returns TRUE on success or FALSE on failure. EXAMPLES
Example #1 Drawing a dashed line <?php $ps = ps_new(); if (!ps_open_file($ps, "polydash.ps")) { print "Cannot open PostScript file "; exit; } ps_set_info($ps, "Creator", "polydash.php"); ps_set_info($ps, "Author", "Uwe Steinmann"); ps_set_info($ps, "Title", "Poly dash example"); ps_begin_page($ps, 596, 842); ps_setpolydash($ps, array(10, 5, 2, 5)); ps_moveto($ps, 100, 100); ps_lineto($ps, 200, 200); ps_stroke($ps); ps_end_page($ps); ps_delete($ps); ?> This example draws a line with a 10 and 2 points long line, and gaps of 5 points inbetween. SEE ALSO
ps_setdash(3). PHP Documentation Group PS_SETPOLYDASH(3)
All times are GMT -4. The time now is 05:17 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy