Sponsored Content
Full Discussion: Fixed length fields
Top Forums Shell Programming and Scripting Fixed length fields Post 302520074 by vgersh99 on Thursday 5th of May 2011 05:22:33 PM
Old 05-05-2011
A bit verbose, but....
Code:
gawk 'BEGIN{FIELDWIDTHS="1 51 49";orderN=split("2 1 3", orderA)}; {for(i=1;i in orderA;i++)printf("%*s%c",FIELDWIDTH[i],$orderA[i],(i==orderN)?ORS:"") }' myFile

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

creating a fixed length output from a variable length input

Is there a command that sets a variable length? I have a input of a variable length field but my output for that field needs to be set to 32 char. Is there such a command? I am on a sun box running ksh Thanks (2 Replies)
Discussion started by: r1500
2 Replies

2. Shell Programming and Scripting

fixed length fields in awk

I am trying to display df -h command out in proper format, how can I display each field of each record in a fixed length. (2 Replies)
Discussion started by: roopla
2 Replies

3. Shell Programming and Scripting

Fixed length (Fill out)

hello, I have a file that has lines with different lengts. I want this file to be filled up with a zero so that al the lines have the same length. Please advice? File 1: ----------- 2310 2009 830 1345 Result File 2: ---------- 2310 2009 0830 (3 Replies)
Discussion started by: peterk
3 Replies

4. UNIX for Dummies Questions & Answers

What the command to find out the record length of a fixed length file?

I want to find out the record length of a fixed length file? I forgot the command. Any body know? (9 Replies)
Discussion started by: tranq01
9 Replies

5. UNIX for Dummies Questions & Answers

Convert a tab delimited/variable length file to fixed length file

Hi, all. I need to convert a file tab delimited/variable length file in AIX to a fixed lenght file delimited by spaces. This is the input file: 10200002<tab>US$ COM<tab>16/12/2008<tab>2,3775<tab>2,3783 19300978<tab>EURO<tab>16/12/2008<tab>3,28523<tab>3,28657 And this is the expected... (2 Replies)
Discussion started by: Everton_Silveir
2 Replies

6. Shell Programming and Scripting

Need awk script to compare 2 fields in fixed length file.

Need a script that manipulates a fixed length file that will compare 2 fields in that file and if they are equal write that line to a new file. i.e. If fields 87-93 = fields 119-125, then write the entire line to a new file. Do this for every line in the file. After we get only the fields... (1 Reply)
Discussion started by: Muga801
1 Replies

7. Shell Programming and Scripting

Make variable length record a fixed length

Very, very new to unix scripting and have a unique situation. I have a file of records that contain 3 records types: (H)eader Records (D)etail Records (T)railer Records The Detail records are 82 bytes in length which is perfect. The Header and Trailer records sometimes are 82 bytes in... (3 Replies)
Discussion started by: jclanc8
3 Replies

8. Shell Programming and Scripting

changing a variable length text to a fixed length

Hi, Can anyone help with a effective solution ? I need to change a variable length text field (between 1 - 18 characters) to a fixed length text of 18 characters with the unused portion, at the end, filled with spaces. The text field is actually field 10 of a .csv file however I could cut... (7 Replies)
Discussion started by: dc18
7 Replies

9. Shell Programming and Scripting

Convert variable length record to fixed length

Hi Team, I have an issue to split the file which is having special chracter(German Char) using awk command. I have a different length records in a file. I am separating the files based on the length using awk command. The command is working fine if the record is not having any... (7 Replies)
Discussion started by: Anthuvan
7 Replies

10. UNIX for Beginners Questions & Answers

Splitting the file based on two fields - Fixed length file

Hi , I am having a scenario where I need to split the file based on two field values. The file is a fixed length file. ex: AA0998703000000000000190510095350019500010005101980301 K 0998703000000000000190510095351019500020005101480 ... (4 Replies)
Discussion started by: saj
4 Replies
Perl::Critic::Policy::ControlStructures::ProhibitLabelsWUserpContriPerl::Critic::Policy::ControlStructures::ProhibitLabelsWithSpecialBlockNames(3)

NAME
Perl::Critic::Policy::ControlStructures::ProhibitLabelsWithSpecialBlockNames - Don't use labels that are the same as the special block names. AFFILIATION
This Policy is part of the core Perl::Critic distribution. DESCRIPTION
When using one of the special Perl blocks "BEGIN", "END", "CHECK", "INIT", and "UNITCHECK", it is easy to mistakenly add a colon to the end of the block name. E.g.: # a BEGIN block that gets executed at compile time. BEGIN { <...code...> } # an ordinary labeled block that gets executed at run time. BEGIN: { <...code...> } The labels "BEGIN:", "END:", etc. are probably errors. This policy prohibits the special Perl block names from being used as labels. CONFIGURATION
This Policy is not configurable except for the standard options. SEE ALSO
The Perl Buzz article on this issue at <http://perlbuzz.com/2008/05/colons-invalidate-your-begin-and-end-blocks.html>. ACKNOWLEDGMENT
Randy Lauen for identifying the problem. AUTHOR
Mike O'Regan COPYRIGHT
Copyright (c) 2008-2011 Mike O'Regan. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.16.3 Perl::Critic::Policy::ControlStructures::ProhibitLabelsWithSpecialBlockNames(3)
All times are GMT -4. The time now is 07:38 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy