Sponsored Content
Top Forums Shell Programming and Scripting awk operation to get table formatted file Post 302966067 by Aia on Monday 8th of February 2016 12:09:29 AM
Old 02-08-2016
Code:
cat cheecky.conf

Code:
[sub_suffix-324]
; generated by mod_identity
exten => int,1,GoSub(mdc_template-3,s,1)
exten => int,n(next_380),Return()
; default action for busy
exten => ext,1,GoSub(mdc_template-3,s,1)
exten => ext,n,Set(PRI_CAUSE=17)
exten => ext,n,HangUp(17)
exten => ext,n(back),Return()
[sub_suffix-424]
; generated by mod_identity
exten => int,1,GoSub(mdc_template-3,s,1)
exten => int,n(next_380),Return()
; default action for busy
exten => ext,1,GoSub(mdc_template-3,s,1)
exten => ext,n,Set(PRI_CAUSE=17)
exten => ext,n,HangUp(17)
exten => ext,n(back),Return()
[sub_suffix-321]
; generated by mod_identity
exten => int,n(next_380),Return()
; default action for busy
exten => ext,n,Set(PRI_CAUSE=17)
exten => ext,n,HangUp(17)
exten => ext,n(back),Return()


Code:
#!/usr/bin/env perl -w
# cheecky.pl
use strict;

my @suf = ("extension", "int_mail", "ext_mail");
while (<>) {
    if( /^\[sub_suffix-(\d+)\]$/ ){
        if ( $suf[0] ){
            display();
            @suf = (undef, "null", "null");
        }
        $suf[0] = $1;
    }
    else {
        /int,.,GoSub/ and $suf[1] = "yes" and next;
        /ext,.,GoSub/ and $suf[2] = "yes";
    }
}
display();

sub display {
    printf "%9s\t%8s\t%8s\n", $suf[0], $suf[1], $suf[2];
}

Code:
perl cheecky.pl cheecky.conf

Code:
extension       int_mail        ext_mail
      324            yes             yes
      424            yes             yes
      321           null            null

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

awk - print formatted without knowing no of cols

Hi, i want to print(f) the content of a file, but i don't know how many columns it has (i.e. it changes from each time my script is run). The number of columns is constant throughout the file. Any suggestions? (8 Replies)
Discussion started by: bistru
8 Replies

2. Shell Programming and Scripting

Formatted output - awk

Hi I have the following records in a file SABN YOURTUBE 000514 7256 SACN XYOUDSDF 000514 7356 SADN KEHLHRSER 000514 7656 SAEN YOURTUBE 000514 7156 SAFN YOURTUBE 000514 7056 I need to put this in the format like this printf '%s %-50s %6s %-6s\n' I am not going to read individual... (3 Replies)
Discussion started by: dhanamurthy
3 Replies

3. UNIX for Dummies Questions & Answers

Problem with formatted printing in AWK

Hi, I want to print 130 fileds using formatted printing in AWK. It looks like awk '{printf ("%7.2f%7.2f...%7.2\n",$1,$2,...,$130)}' inflie>oufile But it gives me an error: Word too long! Can you please help me with this? Is there another way to do this? (1 Reply)
Discussion started by: PHL
1 Replies

4. Shell Programming and Scripting

output - tab formatted - awk

Dear All, Good Day. I would like to hear your suggestions for the following problem: I have a file with 5 columns with some numbers in 16 lines as shown below. Input file: Col 1 Col 2 Col 3 Col 4 Col 5 12 220 2 121 20 234 30 22 9... (3 Replies)
Discussion started by: Fredrick
3 Replies

5. Shell Programming and Scripting

awk, sed, perl assistance in outputting formatted file

Hello, Please advise. Scoured this site, as well as google for answers. However if you do not know what to search for, it's a bit hard to find answers. INPUT: ACTASS= 802 BASECOS= 279 COSNCHG= 3 CUSCOS= 52 UPLDCOS= 2 DESIRED OUTPUT: ACTASS=802 BASECOS=279 (13 Replies)
Discussion started by: abacus
13 Replies

6. Shell Programming and Scripting

awk to convert table-by-row to matrix table

Hello, I need some help to reformat this table-by-row to matrix? infile: site1 A:o,p,q,r,s,t site1 C:y,u site1 T:v,w site1 -:x,z site2 A:p,r,t,v,w,z site2 C:u,y site2 G:q,s site2 -:o,x site3 A:o,q,s,t,u,z site3 C:y site3 T:v,w,x site3 -:p,routfile: SITE o p q r s t v u w x y... (7 Replies)
Discussion started by: yifangt
7 Replies

7. Shell Programming and Scripting

awk --> math-operation in data-record and joining with second file data

Hi! I have a pretty complex job - at least for me! i have two csv-files with meassurement-data: fileA ...... (2 Replies)
Discussion started by: IMPe
2 Replies

8. Shell Programming and Scripting

Multiple Replacement in a Text File in one operation (sed/awk) ?

Hi all, Saying we have two files: 1. A "Reference File" whose content is "Variable Name": "Variable Value" 2. A "Model File" whose content is a model program in which I want to substitute "VariableName" with their respective value to produce a third file "Program File" which would be a... (4 Replies)
Discussion started by: dae
4 Replies

9. Shell Programming and Scripting

awk script to find data in three file and perform replace operation

Have three files. Any other approach with regards to file concatenation or splitting, etc is appreciated If column55(billngtype) of file1 contains YMNC or YPBC then pick the value of column13(documentnumber). Now find this documentnumber in column1(Billdoc) of file2 and grep the corresponding... (4 Replies)
Discussion started by: as7951
4 Replies

10. Shell Programming and Scripting

Processing a formatted file with awk

Hi - I want to interrogate information about my poker hands, sessions are all recorded in a text file in a particular format. Each hand starts with the string <PokerStars> followed by a unique hand reference and other data like date/time. There is then all the information about each hand. My first... (5 Replies)
Discussion started by: rbeech23
5 Replies
SAVELOFIG(3)						   MBK LOGICAL UTILITY FUNCTIONS					      SAVELOFIG(3)

NAME
savelofig - save a logical figure on disk ORIGIN
This software belongs to the ALLIANCE CAD SYSTEM developed by the ASIM team at LIP6 laboratory of Universite Pierre et Marie CURIE, in Paris, France. Web : http://asim.lip6.fr/recherche/alliance/ E-mail : alliance-users@asim.lip6.fr SYNOPSYS
#include "mlu.h" void savelofig(ptfig) lofig_list *ptfig; PARAMETER
ptfig Pointer to the lofig to be written on disk DESCRIPTION
savelofig writes on disk the contents of the figure pointer to by ptfig. All the figure lists are ran through, and the appropriate objects written, independently of the figure mode. The savelofig function in fact performs a call to a driver, choosen by the MBK_OUT_LO(1) environment variable. The directory in which the file is to be written is the one set by MBK_WORK_LIB(1). See MBK_OUT_LO(1), MBK_WORK_LIB(1) and mbkenv(3) for details. ERRORS
"*** mbk error *** not supported logical output format 'xxx'" The environment variable MBK_OUT_LO is not set to a legal logical format. "*** mbk error *** savelofig : could not open file figname.ext" Either the directory or the file are write protected, so it's not possible to open figname.ext, where ext is the file format exten- sion, for writting. EXAMPLE
#include "mlu.h" void save_na2_y() { savelofig(getlofig("na2_y")); } SEE ALSO
mbk(1), mbkenv(3), lofig(3), addlofig(3), getlofig(3), dellofig(3), loadlofig(3), flattenlofig(3), rflattenlofig(3), MBK_OUT_LO(1), MBK_WORK_LIB(1). BUG REPORT
This tool is under development at the ASIM department of the LIP6 laboratory. We need your feedback to improve documentation and tools. ASIM
/LIP6 October 1, 1997 SAVELOFIG(3)
All times are GMT -4. The time now is 04:01 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy