Sponsored Content
Top Forums Shell Programming and Scripting Reformat Header of Variable Length Post 302970750 by Scrutinizer on Monday 11th of April 2016 02:47:20 PM
Old 04-11-2016
Thank you Smilie, you're welcome. I made an adaptation so that it should also work if label a: is missing. Try:

Code:
awk -F\; '
  BEGIN {
    split("a b c d f g", L, " ")
  }
  !/^@/{
    print
    next
  }
  {
    gsub(/[cd]1:[^,]+,|^bc=/,x,$2)
    s=$1 FS "bc="
    n=split($2,F,",")
    for(i=1; i<=n; i++) {
      if(F[i]!~"^" L[i] ":")
        break
      if(F[i]~/^[cd]1:/)
        continue
      s=s F[i] ","
    } 
    sub(/,?$/,";",s)
    print s
  }
' file

So that with
Code:
@S008;bc=b:TGT,c:ATA,d:ACA,f:TCC;
AWTVM...

if would produce:
Code:
@S008;bc=;
AWTVM...


Last edited by Scrutinizer; 04-11-2016 at 03:56 PM..
 

10 More Discussions You Might Find Interesting

1. IP Networking

ethernet header length

When i capture a tcp packet (a normal ACK-RST packet), Snort shows me a total packet lenght of 3C(hex) = 60(dez) and an IpLen of 20(dez) and a TcpLen of 20(dez), so the sizeof the Ethernet header should be: TotalPacketLenght-(IpLen+TcpLen), that would be 60-(20+20) = 20, but i thought that the... (4 Replies)
Discussion started by: atmansiddhi
4 Replies

2. 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

3. Shell Programming and Scripting

how to reformat a file to 80 byte rec length?

I have a variable length file that needs to be reformatted to 80 byte reclen before I ftp it to a customer. What is the best way to do this? I tried using dd if=inputfile of=outputfile conv=noblock cbs=80, and it almost gives me what I need. The output file needs to be 80-byte records, and the last... (4 Replies)
Discussion started by: cmgarcia
4 Replies

4. 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

5. 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

6. 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

7. UNIX for Dummies Questions & Answers

Delete header row and reformat from tab delimited to fixed width

Hello gurus, I have a file in a tab delimited format and a header row. I need a code to delete the header in the file, and convert the file to a fixed width format, with all the columns aligned. Below is a sample of the file:... (4 Replies)
Discussion started by: chumsky
4 Replies

8. Shell Programming and Scripting

Flat file-make field length equal to header length

Hello Everyone, I am stuck with one issue while working on abstract flat file which i have to use as input and load data to table. Input Data- ------ ------------------------ ---- ----------------- WFI001 Xxxxxx Control Work Item A Number of Records ------ ------------------------... (5 Replies)
Discussion started by: sonali.s.more
5 Replies

9. Shell Programming and Scripting

[Solved] How to increment and add variable length numbers to a variable in a loop?

Hi All, I have a file which has hundred of records with fixed number of fields. In each record there is set of 8 characters which represent the duration of that activity. I want to sum up the duration present in all the records for a report. The problem is the duration changes per record so I... (5 Replies)
Discussion started by: danish0909
5 Replies

10. 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
Barcode::UPCE(3pm)					User Contributed Perl Documentation					Barcode::UPCE(3pm)

NAME
GD::Barcode::UPCE - Create UPC-E barcode image with GD SYNOPSIS
ex. CGI use GD::Barcode::UPCE; binmode(STDOUT); print "Content-Type: image/png "; print GD::Barcode::UPCE->new('123456')->plot->png; with Error Check my $oGdBar = GD::Barcode::UPCE->new('123456789'); die $GD::Barcode::UPCE::errStr unless($oGdBar); #Invalid Length DESCRIPTION
GD::Barcode::UPCE is a subclass of GD::Barcode and allows you to create UPC-E barcode image with GD. This module based on "Generate Barcode Ver 1.02 By Shisei Hanai 97/08/22". new $oGdBar = GD::Barcode::UPCE->new($sTxt); Constructor. Creates a GD::Barcode::UPCE object for $sTxt. $sTxt has 6 or 7 or 8 numeric characters([0-9]). If $sTxt has 6 characters, this module adds '0' at the front of $sTxt. and calculates CD for you. If $sTxt has 7 characters, this module calaculates CD for you. plot() $oGd = $oGdBar->plot([Height => $iHeight, NoText => 0 | 1]); creates GD object with barcode image for the $sTxt specified at new method. $iHeight is height of the image. If NoText is 1, the image has no text image of $sTxt. ex. my $oGdB = GD::Barcode::UPCE->new('123456'); my $oGD = $oGdB->plot(NoText=>1, Height => 20); # $sGD is a GD image with Height=>20 pixels, with no text. barcode() $sPtn = $oGdBar->barcode(); returns a barcode pattern in string with '1', 'G' and '0'. '1' means black, 'G' also means black but little bit long, '0' means white. ex. my $oGdB = GD::Barcode::UPCE->new('123456'); my $sPtn = $oGdB->barcode(); # $sPtn = ''; $errStr $GD::Barcode::UPCE::errStr has error message. $text $oGdBar->{$text} has barcode text based on $sTxt specified in new method. AUTHOR
Kawai Takanori GCD00051@nifty.ne.jp COPYRIGHT
The GD::Barocde::UPCE module is Copyright (c) 2000 Kawai Takanori. Japan. All rights reserved. You may distribute under the terms of either the GNU General Public License or the Artistic License, as specified in the Perl README file. SEE ALSO
GD::Barcode perl v5.12.3 2003-05-29 Barcode::UPCE(3pm)
All times are GMT -4. The time now is 06:18 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy