Sponsored Content
Full Discussion: variable fixed-width fields
Top Forums Shell Programming and Scripting variable fixed-width fields Post 302575433 by bartus11 on Monday 21st of November 2011 04:11:27 PM
Old 11-21-2011
There you go:
Code:
awk '{gsub("  +","\t");gsub("\\) +",")\t");sub("^\t","")}1' inputfile

This User Gave Thanks to bartus11 For This Post:
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Fixed Width file using AWK

I am using the following command at the Unix prompt to make my 'infile' into a fixed width file of 100 characters. awk '{printf "%-100s\n",$0}' infile > outfile However, there are some records with a special character "©" These records are using 3 characters in place of one and my record... (2 Replies)
Discussion started by: alok.benjwal
2 Replies

2. Shell Programming and Scripting

Extracting records with unique fields from a fixed width txt file

Greetings, I would like to extract records from a fixed width text file that have unique field elements. Data is structured like this: John A Smith NY Mary C Jones WA Adam J Clark PA Mary Jones WA Fieldname / start-end position Firstname 1-10... (8 Replies)
Discussion started by: sitney
8 Replies

3. UNIX Desktop Questions & Answers

Help with Fixed width File Parsing

I am trying to parse a Fixed width file with data as below. I am trying to assign column values from each record to variables. When I parse the data, the spaces in all coumns are dropped. I would like to retain the spaces as part of the dat stored in the variables. Any help is appreciated. I... (4 Replies)
Discussion started by: sate911
4 Replies

4. Shell Programming and Scripting

Combining Two fixed width columns to a variable length file

Hi, I have two files. File1: File1 contains two fixed width columns ID of 15 characters length and Name is of 100 characters length. ID Name 1-43<<11 spaces>>Swapna<<94 spaces>> 1-234<<10 spaces>>Mani<<96 spaces>> 1-3456<<9 spaces>>Kapil<<95 spaces>> File2: ... (4 Replies)
Discussion started by: manneni prakash
4 Replies

5. Shell Programming and Scripting

Comparing column of variable length anf fixed width file

Hi, I have two input files. File1: ID Name Place 1-234~name1~Newyork 1-34~name2~Boston 1-2345~name3~Hungary File1 is a variable length file where each column is seperated by delimitter "~". File2: ID Country 1-34<<11 SPACES>>USA<<7 spaces>> 1-234<<10 SPACES>>UK<<8... (5 Replies)
Discussion started by: manneni prakash
5 Replies

6. Shell Programming and Scripting

summing up the fields in fixed width file

Hi, I have a fixed width file with some records as given below: " 1000Nalsdjflj243324jljlj" "-0300Njfowjljl309933fsf" " 0010Njsfsjklj342344fsl" I want to sum-up first field values(i.e from 2nd character to 6th character)of each record. so for the above file i want to add (1000 - 300+... (2 Replies)
Discussion started by: srilaxmi
2 Replies

7. Shell Programming and Scripting

Printing Fixed Width Columns

Hi everyone, I have been working on a pretty laborious shellscript (with bash) the last couple weeks that parses my firewall policies (from a Juniper) for me and creates a nifty little columned output. It does so using awk on a line by line basis to pull out the appropriate pieces of each... (4 Replies)
Discussion started by: cixelsyd
4 Replies

8. Shell Programming and Scripting

How to parse fixed-width columns which may include empty fields?

I am trying to selectively display several columns from a db2 query, which gives me a fixed-width output (partial output listed here): --------- -------------------------- ------------ ------ 000 0000000000198012 702 29 000 0000000000198013 ... (9 Replies)
Discussion started by: ahsh79
9 Replies

9. Shell Programming and Scripting

Using printf (or other?) to create variable fixed width text

I would like to use printf (or something else?) to create a line of text that has varying column widths. This will be used to create a fixed width file (with varying column widths). For example, consider variables $1 $2 $3 are equal to a, b, c respectively and they should be printed in column... (10 Replies)
Discussion started by: farrenthorpe
10 Replies

10. Shell Programming and Scripting

Alter Fixed Width File

Thank u so much .Its working fine as expected. ---------- Post updated at 03:41 PM ---------- Previous update was at 01:46 PM ---------- I need one more help. I have another file(fixed length) that will get negative value (ex:-00000000003000) in postion (98 - 112) then i have to... (6 Replies)
Discussion started by: vinus
6 Replies
tokenmt(7ipp)						   IP Quality of Service Modules					     tokenmt(7ipp)

NAME
tokenmt - Single and Two Rate Three Conformance Level Meter DESCRIPTION
The tokenmt module can be configured as a Single or a Two Rate meter. Packets are deemed to belong to one of the three levels - Red, Yellow or Green - depending on the configured rate(s) and the burst sizes. When configured as a Single Rate meter, tokenmt can operate with just the Green and Red levels. Configuration parameters for tokenmt correspond to definitions in RFC- 2697 and RFC- 2698 as follows: Configuring tokenmt as a Single Rate meter (from RFC- 2697): committed_rate - CIR committed_burst - CBS peak_burst - EBS (thus 'peak_burst' for a single rate meter is actually the 'excess burst' in the RFC. However, throughout the text the parameter name "peak burst" is used.) Configuring tokenmt as a Two Rate meter (from RFC- 2698): committed_rate - CIR peak_rate - PIR committed_burst - CBS peak_burst - PBS The meter is implemented using token buckets C and P, which initially hold tokens equivalent to committed and peak burst sizes (bits) respectively. When a packet of size B bits arrive at time t, the following occurs: When operating as a Single Rate meter, the outcome (level) is decided as follows: - Update tokens in C and P o Compute no. of tokens accumulated since the last time packet was seen at the committed rate as T(t) = committed rate * (t - t') (where t' is the time the last packet was seen) o Add T tokens to C up to a maximum of committed burst size. Add remaining tokens ((C+T) - Commited Burst), if any, to P, to a maximum of peak burst size. - Decide outcome o If not color aware o If B <= C, outcome is GREEN and C -= B. o Else, if B <= P, outcome is YELLOW and P -= B. o Else, outcome is Red. o Else, o obtain DSCP from packet o obtain color from color_map, color_map[DSCP] o if (color is GREEN) and (B <= C), outcome is GREEN and C -= B. o Else, if (color is GREEN or YELLOW) and (B <= P), outcome is YELLOW and P -= B. o Else, outcome is RED. Note that if peak_burst and yellow_next_actions are not specified (that is, a single rate meter with two outcomes), the outcome is never YELLOW. When operating as a Two Rate meter, the outcome (level) is decided as follows: - Update tokens in C and P o Compute no. of tokens accumulated since the last time a packet was seen at the committed and peak rates as Tc(t) = committed rate * (t - t') Tp(t) = peak rate * (t - t') (where t' is the time the last packet was seen) o Add Tc to C up to a maximum of committed burst size o Add Tp to P up to a maximum of peak burst size - Decide outcome o If not color aware o If B > P, outcome is RED. o Else, if B > C, outcome is YELLOW and P -= B o Else, outcome is GREEN and C -= B & P -= B o Else, o obtain DSCP from packet o obtain color from color_map, color_map[DSCP] o if (color is RED) or (B > P), outcome is RED o Else, if (color is YELLOW) or (B > C), outcome is YELLOW and P -= B o Else, outcome is GREEN and C -= B & P -= B STATISTICS
The tokenmt module exports the following statistics through kstat: Global statistics: module: tokenmt instance: <action id> name: tokenmt statistics class <action name> epackets <number of packets in error> green_bits <number of bits in green> green_packets <number of packets in green> red_bits <number of bits in red> red_packets <number of packets in red> yellow_bits <number of bits in yellow> yellow packets <number of packets in yellow> FILES
/kernel/ipp/sparcv9/tokenmt 64-bit module (SPARC only.) ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWqos | +-----------------------------+-----------------------------+ SEE ALSO
ipqosconf(1M), dlcosmk(7ipp), dscpmk(7ipp), flowacct(7ipp), ipqos(7ipp), ipgpc(7ipp), tswtclmt(7ipp) RFC 2697, A Single Rate Three Color Marker J. Heinanen, R. Guerin -- The Internet Society, 1999 RFC 2698, A Two Rate Three Color Marker J. Heinanen, R. Guerin -- The Internet Society, 1999 SunOS 5.11 29 Sep 2004 tokenmt(7ipp)
All times are GMT -4. The time now is 05:28 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy