Sponsored Content
Top Forums Shell Programming and Scripting Reformat Header of Variable Length Post 302970746 by Scrutinizer on Monday 11th of April 2016 02:23:28 PM
Old 04-11-2016
Another approach.. Try:
Code:
awk -F\; '
  BEGIN {
    split("bc=a: b: c: d: f: g:",L," ")
  }
  !/^@/{
    print
    next
  }
  {
    gsub(/[cd]1:[^,]+,/,x,$2)
    s=$1 FS
    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

Output:
Code:
@S001;bc=a:GGT,b:GGT,c:TTG,d:ACA,f:TCC,g:TGA;
AWTVM...
@S002;bc=a:GGT,b:GTT,c:ATG,d:ACA,f:TCC,g:TGA;
AWTVM...
@S003;bc=a:GGT,b:GTT,c:TTG,d:AGA,f:TGG,g:TGG;
AWTVM...
@S004;bc=a:GGT,b:GTT,c:ATG,d:ACA,f:TGG,g:AGG;
AWTVM...
@S005;bc=a:GGT,b:TGT,c:AGG;
AWTVM...
@S006;bc=a:GGT,b:TGT;
AWTVM...
@S007;bc=a:GGT,b:TGT,c:ATA,d:ACA,f:TCC;
AWTVM...


Last edited by Scrutinizer; 04-11-2016 at 03:33 PM..
This User Gave Thanks to Scrutinizer For This Post:
 

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
JSONLINT(1)						      General Commands Manual						       JSONLINT(1)

NAME
jsonlint - A JSON syntax validator and formatter tool SYNOPSIS
jsonlint [-v][-s|-S][-f|-F][-ecodec]inputfile.json... DESCRIPTION
This manual page documents briefly the jsonlint commands. OPTIONS
The return status will be 0 if the file is legal JSON, or non-zero otherwise. Use -v to see the warning details. Options are: -v, -s, -S, -f, -F, -e -v, --verbose Show details of lint checking -s, --strict Be strict in what is considered legal JSON (the default) -S, --nonstrict Be loose in what is considered legal JSON -f, --format Reformat the JSON (if legal) to stdout -F, --format-compactly Reformat the JSON simlar to -f, but do so compactly by removing all unnecessary whitespace -e codec, --encoding=codec --input-encoding=codec --output-encoding=codec Set the input and output character encoding codec (e.g., ascii, utf8, utf-16). The -e will set both the input and output encodings to the same thing. If not supplied, the input encoding is guessed according to the JSON specification. The output encoding defaults to UTF-8, and is used when reformatting (via the -f or -F options). When reformatting, all members of objects (associative arrays) are always output in lexigraphical sort order. The default output codec is UTF-8, unless the -e option is provided. Any Unicode characters will be output as literal characters if the encoding per- mits, otherwise they will be -escaped. You can use "-e ascii" to force all Unicode characters to be escaped. AUTHOR
jsonlint was written by Deron Meranda <deron.meranda@gmail.com>. This manual page was written by TANIGUCHI Takaki <takaki@debian.org>, for the Debian project (and may be used by others). 2009-12-01 JSONLINT(1)
All times are GMT -4. The time now is 01:47 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy